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