oracle常用資料庫sql語句

2021-08-28 05:04:05 字數 1070 閱讀 1940

–建立表空間

create bigfile tablespace 表空間名稱 datafile 『表空間路徑』 size 100m autoextend on extent management local autoallocate;

–建立使用者

create user 使用者名稱 identified by 密碼 default tablespace 表空間名稱;

–授權grant create session to 使用者名稱;

grant create table,alter any table,drop any table,create any index,alter any index,drop any index to 使用者名稱;

grant insert any table.update any table,delete any table to 使用者名稱;

grant create procedure to 使用者名稱;

grant create view to 使用者名稱;

grant dba to 使用者名稱;

–刪除使用者

drop user 使用者名稱 cascade;

–刪除表空間

drop tablespace 表空間名稱 including contents and datafiles cascade constraint;

–查詢空表

select table_name from user_tables where num_rows=0 or num_rows is null;

–匯出空表alter table table_name allocate extent;語句

select 『alter table 『||table_name||』 allocate extent;』 from user_tables where num_rows=0 or num_rows is null

–資料庫dmp檔案匯出

exp 使用者名稱/密碼@資料庫sid file=dmp檔案路徑 full=y

–資料庫dmp檔案匯入

imp 使用者名稱/密碼@資料庫sid file=dmp檔案路徑 full=y ignore=y

ORACLE資料庫常用SQL

1.新增乙個表,通過另乙個表的結構和資料 create table product bak as select from product2.如果表存在 insert into product bak select from product 3.同乙個表中,將a欄位的指賦給b欄位 update pro...

Oracle資料庫常用SQL

oracle ora 00984 column not allowed here ora 00984錯誤 列在此處不允許 當資料以char的形式存在時,應加單引號,則插入資料庫就不會出現類似錯誤.oracle實現select的結果集隨機展示 select from tablename order b...

Oracle資料庫常用SQL

oracle資料庫建立例項的過程類似於sql server建立資料庫,oracle乙個例項可以對應多個表空間,乙個表空間對應乙個使用者,根據不同的使用者名稱 密碼登入不同的表空間。因此,建立表空間後,緊接著要建立使用者並為其指定表空間。並授權給該使用者,一般是connect resource dba...