MySQL实战:主键,primary key,唯一,非空

1.创建表
create table test_primary_key(
id int unsigned primary key,
username varchar(20)
);


复合主键
create table test_primary_key3(
id int unsigned,
courseid int unsigned,
username varchar(20),
email varchar(50),
primary key(id,courseid)
);

2.插入数据
(1)insert test_primary_key(id,username) values(1,'king');
(2)insert test_primary_key(id,username) values(1,'king123');
(3)insert test_primary_key(username) values('Queue');

【主键primary key特性】:非空,唯一

相关推荐
-
PHP8种变量类型的详细讲解2025-02-22 00:32:24
-
php+apache 和 php+nginx的区别2025-02-22 00:21:27
-
PHP:与workerman结合实现定时任务2025-02-22 00:15:57
-
Nginx的Rewrite规则与实例2025-02-22 00:15:39
-
MySql中身份证字段的简单脱敏介绍2025-02-22 00:15:36