Oracel备注,序列设置初值


Oracle 下读取表/字段的备注信息
Oracle 通过COMMENT ON TABLE  /  COMMENT ON COLUMN 追加表/字段的备注。

CREATE TABLE "MR_DEPT" (
       "DEPT_ID" NUMBER NOT NULL ,
       "PARENT_ID" NUMBER,
       "DEPT_NAME" CHAR(20) NOT NULL ,
       "STATUS" NUMBER DEFAULT 1 NOT NULL ,
PRIMARY KEY ("DEPT_ID")
);

COMMENT ON TABLE "MR_DEPT" IS '部门表';
COMMENT ON COLUMN "MR_DEPT"."DEPT_ID" IS '部门编号';
COMMENT ON COLUMN "MR_DEPT"."PARENT_ID" IS '上级部门编号';
COMMENT ON COLUMN "MR_DEPT"."DEPT_NAME" IS '部门名';
COMMENT ON COLUMN "MR_DEPT"."STATUS" IS '状态';

 备注加好以后,如何在查询中检索呢?

查询表的备注信息
SELECT
  TABLE_NAME,
  TABLE_TYPE,
  COMMENTS
FROM
  USER_TAB_COMMENTS
WHERE
  TABLE_NAME = 'MR_DEPT;

 查询字段的备注信息

SELECT
  TABLE_NAME,
  COLUMN_NAME,
  COMMENTS
FROM
  USER_COL_COMMENTS
WHERE
  TABLE_NAME = 'MR_DEPT;







Drop Sequence SEQ_TBL_MEMBER_ID;
Alter Sequence SEQ_TBL_MEMBER_ID Increment By 1 ;//递增的频率
CREATE SEQUENCE SEQ_TBL_MEMBER_ID
 INCREMENT BY 1   -- 每次加几个    
 START WITH 1     -- 从1开始计数    
 NOMAXVALUE       -- 不设置最大值   
 NOCYCLE          -- 一直累加,不循环  
 CACHE 10;  
Select SEQ_TBL_MEMBER_ID.NextVal From Dual;
设置序列初值,巧妙利用上面的设置递增功能和nextval功能

你可能感兴趣的:(oracle,备注)