ORACLE: 1.查主键名称: select * from user_constraints where table_name = 'AAA' and constraint_type ='P'; 查主键对应的列: select * from user_cons_columns where table_name = 'AAA' and constraint_name = 'PK_AAA'; (PK_AAA 是主键名) 2.查索引名称: select * from user_indexes whe…
Oracle 获取表的主键.外键以及唯一约束条件 Select a.Owner 主键拥有者, a.table_name 主键表, b.Column_Name 主键列, b.Constraint_Name 主键名 From user_Constraints a, user_Cons_Columns b Where a.Constraint_Type = 'P' --P-主键:R-外键:U-唯一约束 and a.Constraint_Name = b.Constraint_Name And a.Ow…
查询最后一个主键id SELECT IF(MAX(id) IS NULL, 0, MAX(id)) AS maxid FROM users; 查询最小的主键id SELECT IF(MIN(id) IS NULL, 0, MIN(id)) AS minid FROM users; 获得一个新的自增id SELECT IF(MAX(id) IS NULL, 0, (MAX(id) + 1)) AS newid FROM users; 查询最后一条插入的数据 SELECT * FROM users…