oracle 常用命令操作

2021-09-23 15:46:03 字數 2653 閱讀 5153

建立表空間:

- drop tablespace user_temp  including contents and datafiles; 

- drop tablespace user_data including contents and datafiles;

- drop tablespace user_index including contents and datafiles;

- drop user c##amap cascade;

- drop user amap cascade;

- create temporary tablespace user_temp tempfile

autoextend on next 20m maxsize unlimited;

- create tablespace user_data datafile

autoextend on next 40m maxsize unlimited;

- create tablespace user_index logging datafile

autoextend on next 32m maxsize 2048m extent management local;

建立common使用者:

create user c##amap identified by amap default tablespace user_data temporary tablespace user_temp ;
建立local使用者:

create user amap identified by amap default tablespace user_data temporary tablespace user_temp;
使用者授權:

- grant dba to amap;

- grant connect to amap;

- grant resource to amap;

- grant unlimited tablespace to amap;

匯入命令

imp amap/amap@amap file=/opt/oracle/0430.dmp full=y
檢視當前例項:

select status,instance_name from v$instance;
oracle 多個例項互相切換例項

windows中設定環境變數

set oracle_sid=a
linux中設定環境變數

export oracle_sid=a
//啟動sqlplus

sqlplus / as sysdba

1.登入伺服器,切換到oracle使用者,或者以oracle使用者登入

[admin@dataserver ~]$ su - oracle
密碼:

[oracle@dataserver ~]$
2.開啟監聽服務

[oracle@localhost ~]$ lsnrctl start
可以通過lsnrctl status命令檢視oracle***執行狀況

[oracle@localhost ~]$ lsnrctl status
3.以sys使用者身份登入oracle

複製**

[oracle@localhost ~]$ sqlplus /nolog
sql*plus: release 11.2.0.1.0 production on fri dec 1 23:29:19 2017

sql> conn /as sysdba
connected to an idle instance.

切換使用者:

conn 使用者名稱/密碼 [as sysdba],如果是sys使用者一定要寫上as sysdba

4.通過startup命令啟動例項

sql> startup
oracle instance started.

total system … … database mounted. database opened.

二、linux下關閉oracle

1.關閉資料庫例項

sql> shutdown
database closed. database dismounted. oracle instance shut down.

sql> quit

2.關閉***

[oracle@localhost ~]$ lsnrctl stop

Oracle 常用命令

1 檢視當前所有物件 sql select from tab 2 建乙個和a表結構一樣的空表 sql create table b as select from a where 1 2 sql create table b b1,b2,b3 as select a1,a2,a3 from a whe...

oracle常用命令

create insert delete select 建立使用者必須在sys超級管理員下 連線到超級管理員 conn sys as sysdba sys zhuangyan system zhuangyan scott tiger 查出所有 clerk 辦事員 的姓名及其部門名稱,部門的人數.找出...

oracle 常用命令

建立臨時表空間 02createtemporarytablespace os temp 03tempfile c oracle product 10.2.0 oradata os temp.dbf 04size100m 05autoextendon 06next100m maxsize 1024m ...