Home > database >  Mysql how to implement "if a table is empty, there is not, create a table"
Mysql how to implement "if a table is empty, there is not, create a table"

Time:09-27

Mysql how to implement "if a table is empty, does not exist, it create a temporary table"
Give me a hand!

CodePudding user response:

only ask questions will not stick

CodePudding user response:

reference 1st floor kxjrzyk response:
ask questions will not only posted

I am a newcomer, not knot, forgive me

CodePudding user response:

Is question is a bit fuzzy, program, or a stored procedure in judgment

CodePudding user response:

 CREATE TABLE IF NOT EXISTS TB INT (ID); 
TRUNCATE TABLE TB;

Don't so strict, there is no table creation, then whether the new, and before the main existing TRUNCATE line (new table there will be no data anyway, TRUNCATE does not affect the final result)

CodePudding user response:

refer to the second floor yyk7248 response:
Quote: refer to 1st floor kxjrzyk response:

ask questions will not only put

I am a newcomer, not knot, hope forgive me

The size of knot stick button can't see? Operation without complex

CodePudding user response:

 drop table if the exists t_user; 
The create table if not exists t_user (
Id int (11) primary key auto_increment,
The name varchar (50) not null,

);
  • Related