SQL语句的分类

4.
DDL: create,drop
DML : insert update delete select
DCL: grant

a.DDL 数据定义语言 create drop alter
b.DML 数据操作语言 select insert update delete
b.DCL 数据控制语言 grant revoke

粘贴复制 增删改查

CREATE TABLE `rzdata` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`stu_num` int(11) DEFAULT NULL,
`stu_name` varchar(100) DEFAULT NULL,
`stu_age` int(11) DEFAULT NULL,
`createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`createuser` varchar(100) DEFAULT NULL,
`updatetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`updateuser` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE `rzdata_test` (
`stu_num` int(11) DEFAULT NULL,
`stu_name` varchar(100) DEFAULT NULL,
`stu_age` int(11) DEFAULT NULL,
`createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`createuser` varchar(100) DEFAULT NULL,
`updatetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`updateuser` varchar(100) DEFAULT NULL,
PRIMARY KEY (`stu_num`,`stu_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

id 自增长 是非业务系统的唯一标识
num 唯一约束
110 ming
110 hong 抛错

原文地址:https://www.cnblogs.com/xuziyu/p/10371801.html