oracle怎么查看表的主键和索引

277
2024/2/22 9:30:23
栏目: 云计算
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

要查看表的主键和索查,你可以使用以下SQL语句:

  1. 查看表的主键:
SELECT
    cols.column_name,
    cols.position,
    cons.constraint_name
FROM
    all_constraints cons
    JOIN all_cons_columns cols ON cons.constraint_name = cols.constraint_name
WHERE
    cons.constraint_type = 'P'
    AND cols.table_name = 'your_table_name';
  1. 查看表的索引:
SELECT
    index_name,
    column_name,
    column_position
FROM
    all_ind_columns
WHERE
    table_name = 'your_table_name';

请将your_table_name替换为要查看的表名。

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: oracle partition函数如何创建