达梦判断哪列是自增列|查询自增信息|重构自增列|自增改为sequence


### Code Reference
  • URL:p115 DM8系统管理员手册
  • DESC:达梦判断哪列是自增列|查询自增信息|重构自增列|自增改为sequence
  • Last Update:2020-7-1 10:58
    • 判断自增列

      left JOIN (SELECT *
      FROM syscolumns t
      WHERE id =
      (SELECT object_id
      FROM dba_objects t
      WHERE 1=1
      AND t.owner = ‘TEST’
      AND t.object_name = ‘WhichCanEncrypt’
      AND object_type = ‘TABLE’)
      ) t7 on (t7.NAME = t4.COLUMN_NAME)

    • 自增列的属性

      CREATE TABLE test.“aIDENT_TABLE” (
      C1 INT IDENTITY(1, 11),
      C2 INT
      );
      SELECT IDENT_CURRENT(‘TEST.aIDENT_TABLE’);
      SELECT IDENT_SEED(‘TEST.aIDENT_TABLE’);
      SELECT IDENT_INCR(‘TEST.aIDENT_TABLE’);

    • 重构自增信息

      SELECT NAME AS c_columnname,
      (decode(info2, 1, ident_incr(‘TEST.WhichCanEncrypt’), NULL, -1, -2) +
      decode(info2, 1, ident_current(‘TEST.WhichCanEncrypt’), NULL, -1, -2)) AS c_identitycurrent,
      decode(info2, 1, ident_seed(‘TEST.WhichCanEncrypt’), NULL, -1, -2) AS c_identitystartvalue,
      decode(info2, 1, ident_incr(‘TEST.WhichCanEncrypt’), NULL, -1, -2) AS c_identitystep
      FROM sys.syscolumns t
      WHERE id =(SELECT object_id
      FROM dba_objects t
      WHERE t.owner = ‘TEST’
      AND t.object_name = ‘WhichCanEncrypt’
      AND object_type = ‘TABLE’)
      AND info2 = 1;

你可能感兴趣的:(dameng)