mysql创建表,同时加上约束,SQL查看所有表和查看某个表结构;sql删除表

来源:互联网 发布:分数统计软件 编辑:程序博客网 时间:2024/06/14 05:25

create biao;

create table user(

id int primary key auto_increment,

username varchar(20) unique,

password varchar(20) not null

)

约束作用:保证数据的完整性

单表约束类:

主键约束:primary【主要的】  key 必须包含的主键值(主键约束默认就是唯一非空的)

唯一约束:unique【唯一的】 只能是唯一的值

非空约束:not null  不能为空

7 SQL查看所有表和查看某个表结构:

查看所有表: show tables

查看某个表的结构信息:desc 表名;

 

8 SQL 删除表:

删除表:drop table 表名;

原创粉丝点击