数据库
首页 > 数据库> > oracle的常用sql 表的新增,修改,唯一,索引,主键,备注

oracle的常用sql 表的新增,修改,唯一,索引,主键,备注

作者:互联网

1.创建表
create table APP21
(
  id         VARCHAR2(20) not null,
  aae036     DATE,
  nums       NUMBER(14),
  sjzt       VARCHAR2(6) default '0' not null,
  time       DATE default sysdate not null
)

2.分配表空间
tablespace DATA
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );


3添加备注给表字段
comment on table APP21
  is '医保APP订单查询主表';

4.建索引
create index N_APP21_1 on APP21 (AKB020)
  tablespace DATA
  pctfree 10
  initrans 2
  maxtrans 255;

5.eate/Recreate primary, unique and foreign key constraints 
alter table APP21
  add constraint PK_APP21 primary key (ID)
  using index 
  tablespace DATA
  pctfree 10
  initrans 2
  maxtrans 255;
alter table APP21
  add constraint U_APP21_1 unique (HISORDERID)
  using index 
  tablespace DATA
  pctfree 10
  initrans 2
  maxtrans 255;

6.表字段,并添加备注

alter table app21 
add jylsh varchar2(2000);
comment on column app21.jylsh is '交易流水号';
commit;
 

标签:pctfree,APP21,tablespace,sql,oracle,table,DATA,主键,255
来源: https://blog.csdn.net/m0_37735354/article/details/100998577