Oracle,Mysql 獲取用戶下所有表名,獲取表所有的列名及數據類型


Mysql

 
         
下面是mysql獲取數據庫所有表的語句
select table_name from information_schema.TABLES where TABLE_SCHEMA='Username'

information_schema這個是數據系統用來保存數據表的總表
select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables where table_schema = (select database())
拿到表之后,可以獲取表的所有字段。

select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from information_schema.columns
        where table_name = 'tablename' and table_schema = (select database()) order by ordinal_position

 

 

 

Oracle

 
         
獲取用戶所有表
select table_name from user_tables where TABLESPACE_NAME is not null and  user='UserName' 

獲取表字段 SELECT table_name, column_name, data_type FROM all_tab_cols WHERE table_name = 'tablename '

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM