萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> oracle教程 >> Oracle中創建和管理表詳解

Oracle中創建和管理表詳解

以下是對Oracle中的創建和管理表進行了詳細的分析介紹,需要的朋友可以過來參考下  

SQL> /*
SQL> 對於表的操作: 創建表,修改表(添加新的列,改變當前某些列,刪除列),刪除表
SQL> 創建表: create table(需要create table的權限)
SQL> 修改表: alter table tablename add/modify/drop
SQL> 刪除表:drop table tablename
SQL> */
SQL> show user;
USER 為 "SCOTT"
SQL> --訪問hr用戶下的表
SQL> select * from hr.employees;
select * from hr.employees
                 *
第 1 行出現錯誤:
ORA-00942: 表或視圖不存在
SQL> --測試defaul值
SQL> create table test1
  2  (tid number,
  3   tname varchar(20),
  4   hiredate date default sysdate);
表已創建。
SQL> insert into test1(tid,tname) values(1,'Mary');
已創建 1 行。
SQL> select * from test1;
       TID TNAME                HIREDATE                                                                               
---------- -------------------- --------------                                                                         
         1 Mary                 12-6月 -11                                                                             
SQL> --rowid rownum都是偽列
SQL> select rowid,rownum,empno from emp;
ROWID                  ROWNUM      EMPNO                                                                               
------------------ ---------- ----------                                                                               
AAANA2AAEAAAAAsAAT          1       1122                                                                               
AAANA2AAEAAAAAsAAO          2       1234                                                                               
AAANA2AAEAAAAAsAAP          3       1235                                                                               
AAANA2AAEAAAAAsAAQ          4       2222                                                                               
AAANA2AAEAAAAAsAAR          5       2345                                                                               
AAANA2AAEAAAAAsAAS          6       2346                                                                               
AAANA2AAEAAAAAsAAA          7       7369                                        &nb

copyright © 萬盛學電腦網 all rights reserved