ORACLE數據庫操作基本語句


1.登陸SPL*PLUS

[username/password] [@server] as [sysdba|sysoper]
eg. system/password    or     connect sys/password as sysdba

2.查看登錄用戶

show user

dba_users
desc dba_users//展示表結構
select username from dba_users;

3.解鎖用戶

alter user username account unlock

4.表空間

數據庫--->表空間--->數據文件

表空間分類:
永久表空間:  表、視圖,永久保存
臨時表空間:  操作當中的過程,過程結束即被釋放
UNDO表空間:  保存事務所修改數據的舊址,就是被修改之前的數據,用於回滾

5.創建表空間

create [temporary] tablespace tablespace_name tempfile|datafile 'xx.dbf' size xx

永久表空間
create tablespace test1_tablespace 
datafile 'testlfile.dbf' size 10m;

臨時表空間
create temporary temptest1_tablespace
tempfile 'tempfile1.dbf' size 10m;

改變表空間狀態
alter tablespace tablespacename offline|online;聯機||脫機
alter tablespace tablespacename read only|read write;

6.增加/刪除數據文件

增加
alter tablespace tablespace_name add datafile 'xx.dbf' size xx;
刪除
alter tablespace tablespace_name drop datafile 'xx.dbf';

7.表

(1)基本存儲結構
(2)二維結構
(3)行和列

8.數據類型

字符型
char(n)   n<=2000  補充為n位
nchar(n)  n<=1000
varchar2(n) n<=4000
nvarchar2(n)n<=2000

數值型
number(p,s) p有效數字,s小數點后的位數
float(n)

日期型
data
timestamp

其他類型
blob 4GB二進制
clob 4GB字符串

9.管理表

創建表
create table table_name
(
  colimn_name datatype, ...
)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM