Oracle中和MYSQL show create table tablename,desc tablename,show tables, show databases 相似效果。


轉自https://www.xuebuyuan.com/3220375.html

oracle命令執行之前需要設置下輸出格式,不然結果會顯示不全

SET LONG 1000;

SET PAGESIZE 0;

在對MYSQL移植到Oracle時 數據庫一些專有寫法的差異進行備注。

 

1. show create table tablename;

    Oracle: 

select table_name,dbms_metadata.get_ddl('TABLE','TABLE_NAME')from dual,user_tables where table_name='TABLE_NAME'; 
eg:
select table_name,dbms_metadata.get_ddl('TABLE','C')from dual,user_tables where table_name='C'; 

注意:TABLE_NAME 指表名 需要大寫。

 

 

 

 

2. desc tablename;

    Oracle:

select column_name,data_type,nullable from all_tab_columns where owner='LANCE' and table_name='TABLE_NAME';

    注意:TABLE_NAME 指表名 需要大寫。 LANCE為當前用戶名稱。

 

3. show tables 

    Oracle:

select TABLE_NAME from user_tables;
# 查看當前登陸用戶的所屬表
或者
select table_name from all_tables where owner='用戶名';
eg:select table_name from all_tables where owner='SIMON';

     注意:此處 TABLE_NAME 為 user_tables的字段名稱,請不要修改。用戶名需要大寫。

 

4.show  databases

    Oracle: 

select name as database from v$database;

 


免責聲明!

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



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