创建数据库指定表名注释指定列注释创建 创建数据库 CREATE TABLE STUDENT(ID NUMBER PRIMARY KEY,NAME VARCHAR(200) NOT NULL,SEX VARCHAR(200),CREATE_DATE DATE); 指定表名注释 COMMENT ON TABLE STUDENT IS ‘学生表‘; 指
创建数据库
CREATE TABLE STUDENT(ID NUMBER PRIMARY KEY,NAME VARCHAR(200) NOT NULL,SEX VARCHAR(200),CREATE_DATE DATE);指定表名注释
COMMENT ON TABLE STUDENT IS ‘学生表‘;指定列注释
COMMENT ON COLUMN STUDENT.ID IS ‘学生ID‘;COMMENT ON COLUMN STUDENT.NAME IS ‘学生姓名‘;COMMENT ON COLUMN STUDENT.SEX IS ‘学生性别‘;COMMENT ON COLUMN STUDENT.CREATE_DATE IS ‘创建日期‘;创建序列
CREATE SEQUENCE student_seq INCREMENT BY 1 -- 每次增加1个 START WITH 1 --从1开始计数 NOMAXVALUE -- 不设置最大值 NOCYCLE --直累加,不循环 NOCACHE --不建立缓冲区创建触发器
CREATE OR REPLACE TRIGGER STUDENT_TRG BEFORE INSERT ON STUDENT FOR EACH ROW -- WHEN (new.ID is null) 设置主键存在时,不触发触发器BEGIN SELECT STUDENT_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;END;Oracle 创建表并设置主键自增