-- 创建一个名为students的表CREATETABLEstudents(idINTPRIMARYKEY,nameVARCHAR(255)NOTNULL,ageINT);-- 删除students表(如果存在)DROPTABLEIFEXISTSstudents; 1. 2. 3. 4. 5. 6. 7. 8. 9. 在上面的示例中,我们先创建了一个students表,然后使用DROP TABLE IF
-- 创建一个表CREATETABLEcustomers(idINTPRIMARYKEY,nameVARCHAR(100));-- 删除一个存在的表DROPTABLEIFEXISTScustomers;-- 删除一个不存在的表DROPTABLEIFEXISTSorders; 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 在上面的示例中,我们首先创建了一个表customers。然后,我们使用DROP TABLE IF EXISTS语句删...
--创建列表分区(LIST) DROP TABLE IF EXISTS orders; CREATE TABLE orders ( id INT PRIMARY ...
一般drop table if exists是数据库里面的,后面接表名,如:drop table if exists xxx_book 其意思是:如果数据库中存在xxx_book表,就把它从数据库中drop掉。备份sql中一般都有这样的语句,如果是数据库中有这个表,先drop掉,然后create表,然后再进行数据插入。拓展:数据库(Database)是按照数据结...
drop database[if exists] 数据库名 三、表操作 1、CREATE TABLE create table 用于创建新数据库表,更新已存在的表结构使用 alter table ,constraints 表示约束 CREATE TABLE table_name ( column datatype [NULL | NOT NULL] [CONSTRAINTS], column datatype [NULL | NOT NULL] [CONSTRAINTS], ··· );...
TheDROP DATABASE IF EXISTS,DROP TABLE IF EXISTS, andDROP VIEW IF EXISTSstatements are always replicated, even if the database, table, or view to be dropped does not exist on the source. This is to ensure that the object to be dropped no longer exists on either the source or the replic...
drop database if exists school; //如果存在SCHOOL则删除 create database school; //建立库SCHOOL use school; //打开库SCHOOL create table teacher //建立表TEACHER ( id int(3) auto_increment not null primary key, name char(10) not null, address varchar(50) default ‘深圳’, year date ); ...
三、一个建库和建表以及插入数据的实例 drop database if exists school; //如果存在SCHOOL则删除 create database school; //建立库SCHOOL use school; //打开库SCHOOL create table teacher //建立表TEACHER ( id int(3) auto_increment not null primary key, name char(10) not null, address varchar(50...
DROPTABLEIF EXISTS `test`; CREATETABLE`test` ( `id`int(11) unsignedNOTNULLAUTO_INCREMENT, `fieldOne`varchar(255)DEFAULTNULL, `fieldTwo`varchar(255)DEFAULTNULL, `fieldThree`varchar(255)DEFAULTNULL, PRIMARYKEY(`id`) ) ENGINE=MyISAM AUTO_INCREMENT=6DEFAULTCHARSET=gbk; ...
其他关键字说明:auto_increment 自增(此列必须是:primary key或者unique key),unsigned 非负数,comment 注释。 例2:在students数据中创建一个名为courses的表,表结构如下所示: CREATETABLEifnotEXISTScourses( couIDintnotnullprimarykeyauto_increment COMMENT'学号', ...