Oracle创建表、索引、主键、字段描述

时间:2021-10-30 01:40:12
-- 创建表
create table SX04_LBALANCE
(
YEAR VARCHAR2(10) not null,
PROGRAMNO VARCHAR2(40) not null,
FDATE VARCHAR2(10) not null,
FACCTCODE VARCHAR2(50) not null,
FCURCODE VARCHAR2(3) not null,
FAACCCREDIT NUMBER(19,4) default 0 not null,
FAENDBAL NUMBER(19,4) default 0 not null,
FISDETAIL NUMBER(3) not null
)
--表所在表空间
tablespace ISTAUDIT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 152M
minextents 1
maxextents unlimited
);
-- 字段描述
comment on column SX04_LBALANCE.INPUT_DT
is '数据日期';
-- 添加主键
alter table SX04_LBALANCE
add primary key (YEAR, PROGRAMNO, FACCTCODE, FDATE)
using index
tablespace ISTAUDIT
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 93M
minextents 1
maxextents unlimited
);
-- 创建索引 多个索引可连续创建 如下
create index CODE_INDEX on SX04_LBALANCE (FACCTCODE)
tablespace ISTAUDIT
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
create index FDATE_INDEX on SX04_LBALANCE (FDATE)
tablespace ISTAUDIT
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);