oracle常用小知识点备忘录

--DBA用户sys或system登录
--创建临时表空间
create temporary tablespace test_temp
tempfile 'F:\oracle\product\10.2.0\oradata\test_temp.dbf' 
size 500m  
autoextend on  
next 200m maxsize unlimited;  
--创建表空间
create tablespace test  
logging  
datafile 'F:\oracle\product\10.2.0\oradata\test.dbf' 
size 500m  
autoextend on  
next 200m maxsize unlimited;  

--创建用户,并指定表空间
create user orcltest --用户名
identified by test --用户密码
default tablespace test --默认表空间
temporary tablespace test_temp--临时表空间

--给用户授权
grant connect,resource ,dba to orcltest



---导出用户
exp orcltest/test@82  owner=orcltest file=e:\orcltest.dmp log=e:\orcltest.log
--导入用户
imp orcltest/test@orcl fromuser=orcltest touser=orcltest file=e:\orcltest.dmp log=e:\orcltest.log

--DOS下登录
------dba登录---
--1.进入dos
--2.>sqlplus /nolog
--3.>conn sys/orcl@orcl as sysdba

--普通用户登录
--1.进入dos
--2.>sqlplus /nolog
--3.>conn hugetest/test@orcl

--查看数据库字符集
select userenv('language') from dual;
--plsql developer客户端与服务器端字符集不一致引起中文乱码
--环境变量中配置
NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK

--用户解锁
alter user scott account unlock
--锁用户
alter user scott account lock;
--查看用户拥有的表
select * from user_tables;
select * from all_tables;
select * from dba_tables;

--查看用户
select * from dba_users --全数据库用户的详细信息,具有dba权限的用户才可以查看
select * from all_users --所有用户,但是信息较少,就一个username,user_id,created
select * from user_users--当前登录用户信息

--查看用户系统权限
select * from dba_sys_privs;--全数据库用户的系统权限详细信息
select * from user_sys_privs;--当前用户的系统权限
--查看数据库都有哪些角色
select * from dba_roles;
--查看用户拥有的角色
select * from dba_role_privs ;--全库用户拥有的角色权限
select * from user_role_privs;--当前用户拥有的角色权限
--查看用户拥有的对象
select * from dba_tab_privs;
select * from all_tab_privs ;
select * from user_tab_privs;
--查看角色权限
select * from role_sys_privs;
select * from role_role_privs;
select * from role_tab_privs;
select * from role_wm_privs;

--查看用户拥有的表
select * from all_tables where owner='SCOOT'
--查看表中的所有字段
select * from all_tab_columns where table_name='EMP'
--列出表的索引列
select * from sys.all_ind_columns where table_name='EMP'
--查看表的约束
select * from all_constraints where table_name='EMP'
--描述数据字典视图
select table_name ,comments from dictionary where table_name like '%TABLE%'; 

--添加字段
alter table tableName add columnName type;--alter table student add address varchar2(200);
--修改字段类型
alter table tableName modify columnName newType;--alter table student userCode varchar2(200);
--修改字段名称
alter table tableName rename column oldName to newName;--alter table student rename column userCode to code;
--删除字段
alter table tableName drop column columnName;--alter table student drop column code;
--表重命名
rename oldTableName to newTableName;rename student to student1;

--查看共享池
select * from v$sqlarea;
select sql_text,hash_value,parse_calls from v$sqlarea where sql_text like '%xxxxx%'
alter system flush shared_pool;//清空缓冲区










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值