Oracle資料庫筆記(十)

2021-04-01 17:31:45 字數 1662 閱讀 6597

檢視某錶上的約束可以通過all_constraints檢視中檢視,另乙個檢視all_cons_columns也包括組成表上約束列的資訊:

select constraint_name, table_name, r_owner, r_constraint_name

from all_constraints

where table_name = 'table_name' and owner = 'owner_name';

增加表空間的大小有兩種方法:

1.增加額外的資料檔案到表空間中

alter tablespace users add datafile '/u01/oradata/orcl/users02.dbf' size 25m;

2.修改表空間當前的資料檔案

例如:alter database datafile '/u01/oradata/orcl/users01.dbf' resize 50m;

建立序列:

-- create sequence

create sequence seq_number_b007

minvalue 1

maxvalue 999999999999999999999999999

start with 201761

increment by 1

cache 20;

資料庫表字段長度的修改(oracle 8 ):

1.如果表裡沒有資料,那麼欄位的長度、是否為空,可隨便變更;

2.如果表裡有資料,字段定義的長度從小變大,如varchar2(1) 到varchar2(5),可直接用如下語句:

alter table code_line_kind modify(line_kind varchar2(5);

3.如果表裡有資料,字段定義的長度從大變小,如varchar2(5) 到varchar2(1),不能直接用如下語句:

alter table code_line_kind modify(line_kind varchar2(5); 

而需要以下過程:

create table code_line_kind_bak as select * from code_line_kind;

alter table code_line_kind modify (line_kind varchar2(1);

insert into code_line_kind select * from code_line_kind_bak;

commit;

drop table code_line_kind_bak;

4.如果更改字段是否為空的屬性,同3

殺死鎖程序

殺死其鎖程序[sid,serial#],sql語句如下:alter system kill session 『sid,serial#'

資料庫記憶體使用情況查詢

select a.sid,b.name,a.value from v$sesstat a,v$statname b

where (b.name like '%uga%' or b.name like '%pga%') and a.statistic# = b.statistic#

order by value desc;

9i 中程序使用記憶體可以通過 v$process 來檢視 :

desc v$process

oracle資料庫筆記

資料庫的匯入匯出 匯出 備份 exp 使用者名稱 密碼 要連線的遠端計算機ip 搜尋要備份的遠端資料庫名稱 file 檔案路徑 匯入 imp同上 例 exp kw kw2014 192.168.1.114 1521 orcl file f kw.dmp compress y imp kw kw201...

oracle資料庫筆記

基礎知識 1.ddl 資料定義語言。create drop alter 對錶的操作 2.dml 資料操作語言。insert update delete對資料的操作 3.tcl transaction control language 事務控制語言 commit 提交 rollback 取消 4.dq...

Oracle筆記之Oracle資料庫資料型別

1 char 定長,create table tablename filed1 char 32 最大2000個字元,存放時超過報錯,不足補空格。補 dump函式,檢視字段資訊。select filed1,dump filed1 from tablename 2 varchar2 變長,最大4000個...