mysql建立表sql語句

2021-10-01 10:59:35 字數 990 閱讀 2914

直接給出sql語句

drop table if exists `test_table_name`;

create table `test_table_name` (

`id` int(11) not null auto_increment comment '主鍵',

`del_***` int(1) default '1' comment '0刪除;1正常;預設1',

`remark` varchar(1024) default null comment '備註',

`create_by` int(11) not null default '0' comment '建立者',

`create_time` datetime default current_timestamp comment '建立時間',

`update_by` int(11) not null default '0' comment '更新者',

`update_time` datetime default current_timestamp on update current_timestamp comment '更新時間',

primary key (`id`) using btree

) engine=innodb default charset=utf8mb4 comment='測試建立表,字段可以新增';

1、上面sql只列出通用引數的字段,其他字段自行新增

2、drop table if exists `表名`--->如果表已經存在則刪除

3、del_***、remark、create_by、create_time、update_by、update_time為公用引數,每張表都有屬性

備註:如果建表時已經指定字符集為utf8,需要為utfmb4,則執行如下語句

alter table 表名 convert to character set utf8mb4;

sql語句建立表

create table search custom mall id int 11 not null primary keyauto increment,uid int 11 not null name varchar 150 not null search mall id int 11 not n...

mysql語句表 mysql表級sql語句

create table table name id int unsigned primary key auto increment,username varchar 32 not null,nickname varchar 16 not null default 匿名 unique key use...

SQL語句建立臨時表

1.insert into select語句 語句形式為 insert into table2 field1,field2,select value1,value2,from table1 要求目標表table2必須存在,由於目標表table2已經存在,所以我們除了插入源表table1的字段外,還可...