標籤:
一.Oracle簡介
1.Oracle屬於關係型資料庫,是一款可以在Client/Server模式下啟動並執行RDBMS產品。2009年,Oracle公司收購SUN。
2.Oracle是對象關係型資料庫管理系統(ORDBMS)。
3.Oracle資料庫的主要特點。
支援多使用者,大事務量的交易處理。
支援分散式交易處理。
可移植性好。
4.由一個Oracle資料庫和多個執行個體組成。
Oracle資料庫:位於硬碟上實際存放資料的檔案,這些檔案組合在一起成為一個邏輯整體。
Oracle執行個體:位於實體記憶體裡的資料結構,由一個共用的記憶體池和多個後台進程所組成。使用者如果需要存取資料庫裡的資料,必須要通過執行個體才能實現。
區別:執行個體可以操作資料庫,任何時候一個執行個體只能與一個資料庫關聯。大多數情況下,一個資料庫上只有一個執行個體對其進行操作。
5.
sys最大,下來是system,scott許可權最小。
二.sqlplus命令。
cmd>sqlplus scott/[email protected]:1521/orcl
192.168.1.131:1521為伺服器主機ip地址。orcl為資料庫名。
select * from tab; 查看使用者下的表。
desc student; 查看錶結構。
insert into student values(1,‘張三‘,‘男‘); commit 提交 插入記錄。
select * from student; 查看錶中的資料。
ed 打出sql語句,便於修改語句。 改完後 /+斷行符號執行。
修改一個單詞:
create tablespace ma
datafile ‘E:\aaa.DBF‘
size 50M
autoextend on next 50M maxsize 2048M; 建立資料表空間文法。
alter tablespace ma
datafile ‘E:\aaa.DBF‘
size 5M
autoextend on next 5M maxsize 10M; 修改資料表空間。
drop tablespace ma including contents and datafiles; 刪除資料表空間。
create temporary tablespace ma_temp 建立暫存資料表空間。
tempfile ‘E:\aaa.DBF‘
size 5M
autoextend on next 5M maxsize 10M;
create user yxn identified by yxn 建立使用者
default tablespace ma
temporary tablespace ma_temp;
grant connect,resource,dba to yxn; 授權使用者
show linesize 顯示表寬度。
set linesize 150 設定表寬度。
spool e:aaa.txt 將spool之間的內容寫到aaa.txt
spool off;
list 查看緩衝區。
exit; 退出使用者。
col mname for a20; 修改列的寬度。
三.Oracle資料類型
varchar和varchar2的區別?
存null的時候,vachar會自動轉換為" ",而varchar2還是存null。
oracle筆記一