表及列資訊查詢

2022-03-19 09:45:13 字數 1042 閱讀 3564

查某個使用者下指定表名查表的基本資訊,不指定表名則查該使用者下所有的表,segment_type 指定為表型別 也有index 型別

select a.table_name 表名,

b.created 建立時間,

b.last_ddl_time 最後修改時間,

c.last_analyzed 最後分析時間,

c.tablespace_name 表空間,

c.num_rows 行數, --要經過表分析後才精確 分析表可以用 analyze 也可以用系統包 dbms_stats

d.bytes / 1024 / 1024||'m' 大小,

a.comments 表注釋

from user_tab_comments a

inner join user_objects b on a.table_name = b.object_name

inner join user_tables c on b.object_name = c.table_name

inner join user_segments d on c.table_name = d.segment_name

and a.table_name='test2'

and d.segment_type = 'table'

order by num_rows desc

--某個表的列名,資料型別,和注釋

select a.column_name as 列名,

data_type || '(' || data_length || ')' as 資料型別,

b.comments as 注釋說明

from user_tab_columns a

inner join user_col_comments b

on a.column_name = b.column_name

where a.table_name = upper('&table')

and b.table_name = upper('&table')

order by a.column_id

oracle查詢表資訊(索引,外來鍵,列

oracle中查詢表的資訊,包括表名,欄位名,字段型別,主鍵,外來鍵唯一性約束資訊,索引資訊查詢sql如下,希望對大家有所幫助 1 查詢出所有的使用者表 select from user tables 可以查詢出所有的使用者表 select owner,table name from all tab...

MySql 查詢資料庫中所有表及列的資訊

mysql獲取某個資料庫的所有表名 select table name from information schema.tables where table schema your database name mysql獲取某個表的所有欄位名 select column name from info...

oracle查詢表資訊(索引,外來鍵,列等)

oracle中查詢表的資訊,包括表名,欄位名,字段型別,主鍵,外來鍵唯一性約束資訊,索引資訊查詢sql如下,希望對大家有所幫助 1 查詢出所有的使用者表 select from user tables 可以查詢出所有的使用者表 select owner,table name from all tab...