mysql---表操作之创建表

1)查看当前数据库中已有表

show tables;

2)创建表

create table (if not exists) 表名

( 列a定义,

 列b定义, 

 列c定义

);

列定义:列名 数据类型 空值说明 主键说明 默认值

一.列名(Field)

二.数据类型(Type):

1.数值类型:tinyint,smallint,mediumint,int,bigint,float,double

2.日期和时间类型:date(日期),time(时间值或持续时间),year(年份值)

3.字符串类型:char(定长字符串),blob(二进制形式的长文本数据),text(长文本数据)

三.空值说明(Null):

null:Null=yes

not null:Null=no

四.主键说明(Key):

只有一个,由此列可以唯一确定某记录

五.默认值(Default):

若有定义则为定义值,若无则为null

3)查看已有表结构

describe 表名;

4)复制表

create table (if not exists)  表名

like 已有表名;【结构取自已有表】

as (已知表记录);【结构和数据取自已有表】

猜你喜欢

转载自blog.csdn.net/weixin_39317792/article/details/81187589