常用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';


 


 

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