orcale常用指令

2021-09-29 03:19:20 字數 1600 閱讀 8284

#######建立表空間

create tablespace tbs_***_***

datafile 『h:/oracle/oradata/tbs_***_***.dbf』

size 512m

autoextend on

next 512m maxsize 512m

autoallocate

extent management local

segment space management auto;

#######建立使用者

create user *** identified by 「***」 default tablespace tbs_***_*** profile default;

######給使用者管理許可權

grant dba,resource,connect to ***;

#########匯入資料庫

imp 使用者名稱/密碼@例項名 file=匯入的dmp檔案路徑 full=y

imp mhwz/mhwz@orcl file=‪e:\myecplise_workspace\mhwz\webroot\資料庫\mhwz.dmp full=y ignore=y statistics=none

set nls_lang=american_america.al32utf8

tbs_ronch_misc

select file#,name from v$datafile;

select username,default_tablespace from dba_users;

刪除user。

drop user xx cascade

drop user misc cascade

刪除表空間。

drop tablespace tablespace_name including contents and datafiles;

drop tablespace tbs_ronch_misc including contents and datafiles;

刪除空的表空間,不包含物理檔案。

drop tablespace tablespace_name;

刪除空表空間,包含物理檔案。

drop tablespace tablespace_name including datafiles;

刪除非空表空間,不包含物理檔案。

drop tablespace tablespace_name including datafiles;

刪除非空表空間,包含物理檔案。

drop tablespace tablespace_name including contents and datafiles;

###刪除表

select 『drop table 『||table_name||』;』 from cat where table_type=『table』 order by table_name;

這個查詢的是cat表,查詢的結果條數會大於上一種,因為裡面包含了bin$開頭的表,oracle中刪除表後會有殘留,如果想要把這些殘留的表也刪除就要中這個查詢sql了,然後像上一種方法一樣

將查詢結果複製一下,在sql命令視窗裡再執行一次就刪除了所有的表。

ORCALE常用的連線

跟上學時記不住數學公式一樣,這個內連線 左連線 右連線 全連線總是記不住。今天寫個demo記下來,sql可以copy直接使用。要用的時候,查下就行。o o哈哈 這裡主要比較 inner join left join right join full join 區別 drop table l purge...

mysql常用指令 Mysql常用指令

mysql常用指令2021 01 19 23 40 45 作用 去除select 查詢出來的結果中重複的資料,重複資料只展示一列.關鍵字 distinct 用法 select distinct source from student table source 去重的字段條件 student tabl...

常用到的orcale資料庫方法

判斷是不是時間格式 create or replace function is date mystr varchar2 return varchar2 isstr varchar2 400 isdate varchar2 10 mydate date begin isdate n str trim ...