1先创建表,并设置主键
create table A (
ID NUMBER,
NAME VARCHAR2(20),
SEX VARCHAR2(20)
);
1.1主键设置
alter table A add constraint pk_id primary key(id);
2
备注表名,列名
comment on table A is '人员信息表';
comment on column A.ID is 'ID';
comment on column A.NAME is '姓名';
comment on column A.SEX is '性别';
3设置ID自增序列
create sequence A_SEQ
minvalue 1
maxvalue 999999999999999999
start with 1
increment by 1
cache 20;
4查看主键信息
select a.constraint_name, a.column_name
from user_cons_columns a, user_constraints b
where a.constraint_name = b.constraint_name
and b.constraint_type = 'P'
and a.table_name = 'A' ----A为表名需要大写
5插入一条数据
insert into A(ID,NAME,SEX)
values(1,'张三','男');
create table A (
ID NUMBER,
NAME VARCHAR2(20),
SEX VARCHAR2(20)
);
1.1主键设置
alter table A add constraint pk_id primary key(id);
2
备注表名,列名
comment on table A is '人员信息表';
comment on column A.ID is 'ID';
comment on column A.NAME is '姓名';
comment on column A.SEX is '性别';
3设置ID自增序列
create sequence A_SEQ
minvalue 1
maxvalue 999999999999999999
start with 1
increment by 1
cache 20;
4查看主键信息
select a.constraint_name, a.column_name
from user_cons_columns a, user_constraints b
where a.constraint_name = b.constraint_name
and b.constraint_type = 'P'
and a.table_name = 'A' ----A为表名需要大写
5插入一条数据
insert into A(ID,NAME,SEX)
values(1,'张三','男');