SQL> /*
SQL> 對於表的操作: 創建表
SQL> 創建表: create table(需要create table的權限)
SQL> 修改表: alter table tablename add/modify/drop
SQL> 刪除表
SQL> */
SQL> show user;
USER 為 "SCOTT"
SQL>
SQL> select * from hr
select * from hr
*
第
ORA
SQL>
SQL> create table test
表已創建
SQL> insert into test
已創建
SQL> select * from test
TID TNAME HIREDATE
SQL>
SQL> select rowid
ROWID ROWNUM EMPNO
AAANA
AAANA
AAANA
AAANA
AAANA
AAANA
AAANA
AAANA
AAANA
AAANA
AAANA
ROWID ROWNUM EMPNO
AAANA
AAANA
AAANA
AAANA
AAANA
AAANA
AAANA
AAANA
AAANA
已選擇
SQL>
SQL>
SQL> create table testchar
表已創建
SQL> insert into testchar values(
已創建
SQL> select * from testchar;
C V
a b
SQL> select concat(c
CONCAT CONCAT
a # b#
SQL>
SQL> alter table testchar
表已更改
SQL> desc testchar;
名稱 是否為空? 類型
C CHAR(
V VARCHAR
HIREDATE DATE
SQL>
SQL> alter table testchar
表已更改
SQL> desc testchar;
名稱 是否為空? 類型
C CHAR(
V VARCHAR
HIREDATE DATE
SQL>
SQL> alter table testchar
drop hiredate
*
第
ORA
SQL> ed
已寫入 file afiedt
SQL> /
表已更改
SQL> desc testchar;
名稱 是否為空? 類型
C CHAR(
V VARCHAR
SQL> host cls
SQL>
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
EMP
EMP
TEST
BIN$gNM
TESTDELETE TABLE
TESTCHAR TABLE
已選擇
SQL> drop table testdelete;
表已刪除
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
EMP
EMP
TEST
BIN$gNM
TESTCHAR TABLE
BIN$aJrS
已選擇
SQL>
SQL> drop table test
表已刪除
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
EMP
EMP
BIN$gNM
TESTCHAR TABLE
BIN$aJrS
已選擇
SQL>
SQL>
SQL> show recyclebin;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
TESTDELETE BIN$aJrS
TESTDELETE BIN$gNM
SQL>
SQL> purge recyclebin;
回收站已清空
SQL> show recyclebin;
SQL>
SQL>
SQL> create table myuser
deptno number constraint fk refereneces dept(deptno)
*
第
ORA
SQL> create table myuser
deptno number constraint fk refereneces dept(deptno)
*
第
ORA
SQL> ed
已寫入 file afiedt
SQL> /
表已創建
SQL> desc myuser;
名稱 是否為空? 類型
USERID NOT NULL NUMBER
USERNAME NOT NULL VARCHAR
GENDER VARCHAR
EMAIL NOT NULL VARCHAR
DEPTNO NUMBER
SQL> insert into myuser values(
已創建
SQL> insert into myuser values(
insert into myuser values(
*
第
ORA
SQL> insert into myuser values(
insert into myuser values(
*
第
ORA
SQL>
SQL> spool off
From:http://tw.wingwit.com/Article/program/Oracle/201311/19039.html