oracle实验5:查询当前用户的所有表和视图

实验5:查询当前用户的所有表和视图

SQL> conn scott/scott
已连接。

SQL> select * from tab;

TNAME                               TABTYPE  CLUSTERID                              
------------------------------ ------- ----------                              
DEPT                                    TABLE                                           
EMP                                      TABLE                                           
BONUS                                 TABLE                                           
SALGRADE                            TABLE                                                                                                                   

已选择4行。

显示当前用户的所有表和视图。tab是数据字典。

 

SQL> select * from dept;

    DEPTNO DNAME          LOC                                                  
---------- -------------- -------------                                        
        -3                                                                     
        10 ACCOUNTING     NEW YORK                                             
        20 RESEARCH         DALLAS                                               
        30 SALES               CHICAGO                                              
        40 OPERATIONS      BOSTON                                               

SQL> select * from emp;

     EMPNO ENAME      JOB              MGR HIREDATE              SAL       COMM     DEPTNO
---------- ---------- --------- ---------- -------------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-12月-80            800                          20
      7499 ALLEN      SALESMAN     7698 20-2月 -81           1600        300            30  
      7521 WARD      SALESMAN     7698 22-2月 -81           1250        500            30                                                                    
      7566 JONES      MANAGER      7839 02-4月 -81           2975                          20                                                                     
      7654 MARTIN     SALESMAN    7698 28-9月 -81           1250       1400            30
      7698 BLAKE      MANAGER      7839 01-5月 -81           2850                          30                                                                    
      7782 CLARK      MANAGER      7839 09-6月 -81           2450                          10                                                                     
      7839 KING       PRESIDENT             17-11月-81            5000                         10                                                                     
      7844 TURNER     SALESMAN    7698 08-9月 -81            1500             0          30                                                         
      7900 JAMES      CLERK           7698 03-12月-81            950                          30
      7902 FORD       ANALYST        7566 03-12月-81           3000                         20
      7934 MILLER     CLERK           7782 23-1月 -82           1300                          10

已选择12行。

*代表所有的列。

 

查看emp的表结构

SQL> desc emp 名称                   是否为空? 类型
 -------------------------------- ----------- ----------------------
 EMPNO                                     NOT NULL NUMBER(4)
 ENAME                                                    VARCHAR2(10)
 JOB                                                        VARCHAR2(9)
 MGR                                                       NUMBER(4)
 HIREDATE                                               DATE
 SAL                                                        NUMBER(7,2)
 COMM                                                     NUMBER(7,2)
 DEPTNO                                                  NUMBER(2)

 

书写SQL语句的原则

  • 大小写不敏感,但单、双引号内的大小写敏感
  • 关键字不能缩写
  • 可以跨行,关键字不能跨行,单引号内不能跨行
  • 一般每个字句一行
  • 可以排版增加可读性
  • 字符串用单引号
  • 列的别名用双引

返回目录  http://www.cnblogs.com/downpour/p/3155689.html

 

posted on 2013-06-17 23:04  不吃鱼的小胖猫  阅读(3899)  评论(0编辑  收藏  举报