insert into students(stu_name, gender, age)
values('zhangsan', '男', 23);
--定义主键约束有两种方法
--(直接在建表时定义)
create table students(
stu_no number(4) primary key not null,
stu_name varchar2(20) not null,
gender char(2) not null,
age number(3)
);
--先创建数据库表,再为表添加约束
create table students(
stu_no number(4) not null,
stu_name varchar2(20) not null,
gender char(2) not null,
age number(3)
);
--添加约束语法
--alter table 表名
--add constraints 约束名 约束类型(列名);
alter table students
add constraints pk_no primary key(stu_no);
insert into students(stu_no, stu_name, gender, age)
values(1, 'zhangsan', '男', 23);
insert into students(stu_no, stu_name, gender, age)
values(2, 'zhangsan', '男', 21);
values('zhangsan', '男', 23);
--定义主键约束有两种方法
--(直接在建表时定义)
create table students(
stu_no number(4) primary key not null,
stu_name varchar2(20) not null,
gender char(2) not null,
age number(3)
);
--先创建数据库表,再为表添加约束
create table students(
stu_no number(4) not null,
stu_name varchar2(20) not null,
gender char(2) not null,
age number(3)
);
--添加约束语法
--alter table 表名
--add constraints 约束名 约束类型(列名);
alter table students
add constraints pk_no primary key(stu_no);
insert into students(stu_no, stu_name, gender, age)
values(1, 'zhangsan', '男', 23);
insert into students(stu_no, stu_name, gender, age)
values(2, 'zhangsan', '男', 21);