oracle shell中查询表table的主键primary key的命令
数据库中表的主键是一种标识,其可以唯一标识表中的row(即某个row的主键值和其他row的主键值一定不同)。通常由数据库中的1个或者多个字段构成,如果主键由多个字段构成,那么该主键被称为“联合主键”。
在数据库的操作过程中,经常需要知道某个table的主键,在oracle shell中查询某个表的主键命令为:
select cu.* from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'P' and au.table_name ='CUSTOMER';
# 其中表名为CUSTOMER