创建表
1
2
3
4
5
6
7
8
9
10
11
|
create
table
CAPITAL_ADJUST
(
CAPITAL_ID VARCHAR2(10),
CAPITAL_NAME VARCHAR2(50),
TYPE VARCHAR2(10),
BELONG VARCHAR2(50),
IN_DEP VARCHAR2(50),
ID VARCHAR2(10)
not
null
,
IN_DEP_LEADER VARCHAR2(50),
OUT_DEP_LEAD VARCHAR2(50)
)
|
给列添加注释
1
|
comment
on
column
CAPITAL_ADJUST.CAPITAL_ID
is
'资产编号'
;
|
创建主键约束
1
|
alter
table
CAPITAL_ADJUST
add
constraint
PK_CAPITAL
primary
key
(ID);
|
插入数据
1
2
3
4
5
6
7
8
9
10
11
|
INSERT
INTO
CAPITAL_ADJUST
(ID,
CAPITAL_ID,
CAPITAL_NAME,
TYPE,
BELONG,
IN_DEP,
IN_DEP_LEADER,
OUT_DEP_LEAD)
VALUES
(1,
'001'
,
'电脑'
,
'V001'
,
'部门1'
,
'部门2'
,
'调入负责人'
,
'调出负责人'
);
|
删除数据
1
|
DELETE
FROM
CAPITAL_ADJUST T
WHERE
T.ID = 1;
|
修改表
1
|
ALTER
TABLE
CAPITAL_ADJUST
DROP
COLUMN
OUT_DEP_LEAD;
|
查看数据库编码格式
1
|
select
userenv(
'language'
)
from
dual;
|
创建序列
1
2
3
4
5
6
7
8
|
create
sequence
WLXX_JBXX
start
with
1
increment
by
1
minvalue 1
nomaxvalue
nocycle
nocache
noorder;
|
增加主键
1
2
3
|
alter
table
WL_B_WLGSGLY
add
constraint
PK_WL_B_WLGSGLY
primary
key
(pzid);
|
获得表和列注释
1
|
select
*
from
user_col_comments cc
where
cc.table_name=
'SYS_B_YWXT'
;
|
修改列名
1
2
|
AlTER
TABLE
GJ_B_FL RENAME
COLUMN
分类ID
TO
FLID
select
*
from
USER_TAB_COMMENTS t
where
t.co=
'SYS_B_YWXT'
|
增加列
1
|
alter
table
Tablename
add
(column1 varchar2(20),column2 number(7,2)...)
|
删除列
1
|
alter
table
JJXM_ZLJD_B_CJDW
drop
column
XCDB
|
本文转自 乌英达姆 51CTO博客,原文链接:http://blog.51cto.com/7156680/1790830