Oracle创建表和自增长主键

来源:互联网 发布:淘宝怎么做流量 编辑:程序博客网 时间:2024/05/29 04:47

/*创建表 不带自动标示*/
create table product
(
       pid number(15) primary key not null,
       pname varchar2(20) not null
);
commit;

insert into product(pid,pname) values(1,'美瞳');
commit;

/*清楚表记录*/

truncate table product;
commit;

select * from Product;
/*查看表结构*/
desc product

drop table orders;
/*创建表 带自动标示*/
create table orders
(
       oid number(15) primary key not null,
       pname varchar2(50) not null
);
create sequence oid_id start with 001001 cache 2;/*创建自动标示序列*/

insert into orders(oid,pname) values(oid_id.nextval,'美瞳');
commit;


原创粉丝点击