oracle常用語句

2021-10-18 18:21:46 字數 2694 閱讀 4546

1、新建表空間

create tablespace table_space

datafile 'd:\oracledb\table_space.dbf'

size 500m

autoextend on next 100m

maxsize unlimited;

2、建立臨時表空間

create temporary tablespace temporary_tablespace_name

tempfile 'd:\oracledb\table_temp.dbf'

size 500m

autoextend on

next 100m maxsize unlimited

extent management local;

3、刪除表空間及資料庫檔案

drop tablespace tablespace_name including contents and datafiles;
4、建立使用者

create user username identified by password

profile default

default tablespace tablespace_name

temporary tablespace temporary_tablespace_name

account unlock;

5、賦予授權

grant connect,resource to username ;

grant create any sequence to username ;

grant create any table to username ;

grant delete any table to username ;

grant insert any table to username ;

grant select any table to username ;

grant unlimited tablespace to username ;

grant execute any procedure to username ;

grant update any table to username ;

grant create any view to username ;

(2)自家常用賦權

grant connect,dba,resource to ksfz ;
6、刪除使用者

drop user  user_name cascade ;
7、匯出資料庫

(1)原始方式

exp user_name/pass_word@db_name file=d:\work\temp\file_name.dmp
(2)資料幫浦方式

--1、建立directory

create directory dict_name as 'path';

--例如:

create directory myorabak as 'd:/orabak';

--2、給目標使用者授權

grant read,write on directory dict_name to user_name;

--例如:

grant read,write on directory myorabak to orcl;

#3、匯出

#(1)匯出表結構

expdp user_name/pass_word@db_name directory=dict_name dumpfile=file_name.dmp version=goal_oracle_version content=metadata_only

#例如expdp test/test@orcl directory=myorabak dumpfile=bdap20210202.dmp version=11.2.0.1.0 content=metadata_only

#(2)匯出表

expdp user_name/pass_word@db_name directory=dict_name dumpfile=file_name.dmp version=goal_oracle_version

8、資料庫匯入

(1)原始方式

imp user_name/pass_word@db_name file=d:\... full=y
(2)資料幫浦方式

--1、建立本地的directory

create directory myorabak as 'd:\oracledb';create or replace directory myorabak as 'd:\oracledb';

--2、本地授權

grant read,write on directory myorabak to bdap;

#3、匯入

impdp bdap/bdap@orcl directory=myorabak dumpfile=bdap20210202_indb.dmp transform=segment_attributes:n;

oracle 常用語句

oracle 產看表空間 select total.name tablespace name free space,total space free space used space,total space from select tablespace name,sum bytes 1024 102...

oracle常用語句

drop tablespace crm online space including contents and datafiles 刪除表空間 drop user wuliu01 cascade 刪除使用者 exp orcl file d dmp 匯出資料庫 imp orcl file e alen...

oracle 常用語句

oracle 常用語句 查詢表的大小 select t.owner,t.segment name,sum t.blocks 8 1024 m as s,t.segment type from dba segments t where t.owner user name group by t.owne...