mysql建表脚本注意事项
下文笔者讲述mysql脚本建表时-注意事项,如下所示
在mysql建表时,我们需判断表是否存在
建库时,我们需先判断数据库是否存在
那么如何进行相关的判断呢?
下文笔者将一一道来,如下所示
例:
1.使用 create table if not exists tablename
create table if not exists user_login(keyId int auto_increment primary key not null,
user varchar(90),
pwd varchar(90));
2.从模板表创建表:
CREATE TABLE IF NOT EXISTS table1 LIKE table2;
3.数据库不存在则创建
create database `dbName` if not exists oldDbName;
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


