ORACLE对表的操作,创建表,添加注释,添加列,修改列,删除列,删除表。
创建SEQUENCE
--创建表的基本语句
CREATE TABLE table_name(
column_name type,
column_name type,
column_name type,
column_name type,
PRIMARY KEY(column_name)
);
--创建表的例子
CREATE TABLE USER_TBL(
SEQUENCE_NO VARCHAR2(27),
USER_ID VARCHAR2(10),
USER_NAME VARCHAR2(30),
USER_BIRTH DATE,
USER_AGE NUMBER(3),
PRIMARY KEY(SEQUENCE_NO)
);
--添加注释
COMMENT ON TABLE USER_TBL IS '用户信息表';
COMMENT ON COLUMN USER_TBL.SEQUENCE_NO IS '顺番';
COMMENT ON COLUMN USER_TBL.USER_ID IS '用户ID';
COMMENT ON COLUMN USER_TBL.USER_NAME IS '用户名';
COMMENT ON COLUMN USER_TBL.USER_BIRTH IS '出生日期';
COMMENT ON COLUMN USER_TBL.USER_AGE IS '年龄';
--给表添加列
ALTER TABLE USER_TBL ADD COMMENTS VARCHAR2(3000);
COMMENT ON COLUMN USER_TBL.COMMENTS IS '备考';
--给表添加多列
ALTER TABLE USER_TBL ADD(SEX VARCHAR2(1) DEFAULT 'N',
EDUCATION VARCHAR2(10));
COMMENT ON COLUMN USER_TBL.SEX IS '性别';
COMMENT ON COLUMN USER_TBL.EDUCATION IS '学历';
ALTER TABLE USER_TBL ADD TEST VARCHAR2(10);
--修改列属性
ALTER TABLE USER_TBL MODIFY TEST VARCHAR2(5);
--删除列
ALTER TABLE USER_TBL DROP COLUMN TEST;
--给表重命名
RENAME USER_TBL TO ADMIN_TBL;
--删除表
DROP TABLE ADMIN_TBL;
--创建SEQUENCE
CREATE SEQUENCE SEQ_USER_BLE
INCREMENT BY 1
START WITH 1
NOMAXVALUE
NOMINVALUE
NOCYCLE
NOORDER
CACHE 10
/
--SEQUENCE应用
SEQ_USER_BLE.NEXTVAL
附件是oralc字段类型详解。