常用sql語句-Oracle

1、oracle中給某個用戶某張表的查詢權限
1-1、userA數據庫,給tableA分表的查詢權限
grant select on tableA to userB;
2-2、userB數據庫,創建同義詞,以便於直接訪問視圖
create or replace synonym tableA for userA.tableA;
不創建同義詞則userB用戶通過下面語句訪問
select *  from userA.tableA;
創建同義詞後直接訪問
select *  from tableA;
2、更改歸檔日誌大小解決ORA-00257:archiver error
2-1、查看參數'db_recovery_file_dest_size'值
SQL> show parameter db_recov

2-2、更改參數'db_recovery_file_dest_size'值大小
SQL> alter system set db_recovery_file_dest_size=51820M scope=spfile;
System altered.

3、生成創建表空間語句
SQL> select 'create tablespace '||tablespace_name||' datafile '||file_name||' size 1G autoextend on next 256M;' from dba_data_files;

create tablespace TBS_TC_DATA datafile '/data/app/oracle/oradata/orcl/tbs_tc_data01.dbf' size 1G autoextend on next 256M;

create tablespace NNC_DATA01 datafile '/data/app/oracle/oradata/orcl/nnc_data01_01.dbf' size 1G autoextend on next 256M;

create tablespace TBS_DIREP datafile '/data/app/oracle/oradata/orcl/tbs_direp_01.dbf' size 1G autoextend on next 256M;

alter tablespace TBS_DIREP add datafile '/data/app/oracle/oradata/orcl/tbs_direp_02.dbf' size 1G autoextend on next 256M;

alter tablespace TBS_DIREP add datafile '/data/app/oracle/oradata/orcl/tbs_direp_03.dbf' size 1G autoextend on next 256M;

create tablespace TBS_BIDW datafile '/data/app/oracle/oradata/orcl/tbs_bidw_01.dbf' size 1G autoextend on next 256M;

alter tablespace TBS_BIDW add datafile '/data/app/oracle/oradata/orcl/tbs_bidw_02.dbf' size 1G autoextend on next 256M;

create tablespace TBS_BIODS datafile '/data/app/oracle/oradata/orcl/tbs_bidos_01.dbf' size 1G autoextend on next 256M;

alter tablespace TBS_BIODS add datafile '/data/app/oracle/oradata/orcl/tbs_bidos_02.dbf' size 1G autoextend on next 256M;

create tablespace TBS_BI_DATA datafile '/data/app/oracle/oradata/orcl/tbs_bi_data_01.dbf' size 1G autoextend on next 256M;

create tablespace TBS_PORTAL datafile '/data/app/oracle/oradata/orcl/tbs_portal_01.dbf' size 1G autoextend on next 256M;

create tablespace NNC_DATA02 datafile '/data/app/oracle/oradata/orcl/nnc_data02_01.dbf' size 1G autoextend on next 256M;

create tablespace NNC_DATA03 datafile '/data/app/oracle/oradata/orcl/nnc_data03_01.dbf' size 1G autoextend on next 256M;

create tablespace NNC_IUFO datafile '/data/app/oracle/oradata/orcl/nnc_iufo_01.dbf' size 1G autoextend on next 256M;

create tablespace NNC_INDEX01 datafile '/data/app/oracle/oradata/orcl/nnc_index01_01.dbf' size 1G autoextend on next 256M;

create tablespace NNC_INDEX02 datafile '/data/app/oracle/oradata/orcl/nnc_index02_01.dbf' size 1G autoextend on next 256M;

create tablespace NNC_INDEX03 datafile '/data/app/oracle/oradata/orcl/nnc_index03_01.dbf' size 1G autoextend on next 256M;

4、生成創建用戶語句
SQL> select 'create user '||username||' identified by 123456;' from dba_tables order by created;
5、查詢連接數據庫的service名字
SQL> show parameter service
NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
service_names                 string     orcl

6、查詢用戶
SQL> select username,password from dba_users order by created desc;
7、
刪除當前用戶以及當前用戶所有表、索引
drop user user_name cascade;

8、查詢表空間
select username,default_tablespace from dba_users order by created desc;

SQL> select username,default_tablespace from dba_users where default_tablespace='USERS';


 


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章