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;

 

posted @ 2020-05-22 18:09  士官长  阅读(2834)  评论(0编辑  收藏  举报