1、查看用户拥有的数据库对象
select object_name from user_objects;
系统表总结:
USER_TABLES
USER_SEQUENCES
USER_VIEWS
USER_INDEXES
USER_CONSTRAINTS
USER_OBJECTS
SESSION_PRIVS
2、查看约束信息
select constraint_name from user_constraints;
3、查看用户拥有的表
select table_name from
4、查看用户拥有的视图
select view_name from user_views;
5 、查看用户拥有的触发器
select trigger_name from user_triggers;
6 、查看用户拥有的序列
select sequence_name from user_sequences;
7 、查看用户拥有的存储过程
select object_name from user_procedures;
8、 查看用户拥有的索引
select index_name from user_indexes;
9、 显示当前用户
show user; 不是 SQL 语句,是一个 oracle 提供的 sqlplus 命令
10、切换用户
conn 用户名/密码
11、以数据库管理员的身份登录
conn sys/密码 as sysdba;
12、查看所有的用户
select username from dba_users; dba_users 只有管理员才有这张表
13、查看用户拥有的权限
select * from session_privs;
常用权限
CREATE SESSION 连接数据库
CREATE TABLE 创建表
CREATE VIEW 创建视图
CREATE SEQUENCE 创建序列
CREATE PROCEDURE 创建存储过程
CREATE TRIGGER 创建触发器
CREATE INDEXTYPE 创建索引
UNLIMITED TABLESPACE 对表空间的使用
14、给用户加锁
alter user scott account lock;
15、给用户解锁
alter user scott account unlock;
16、修改用户密码
alter user 所要修改密码的用户名 identified by 新密码;
17、新建用户
create user 用户名 identified by 密码;
18、删除用户及相关对象
drop user 用户名 cascade;
19、给用户授权(多个采用逗号间隔)
grant create session, create table to 用户名;
20、分配空间 XXX 给用户
create table t_local(id number(10), name varchar2(30))
以上出现无法创建表,主要原因在于没有分配表空间,也就是我们新建的表不知道放到什么 地方。
alter user scott default tablespace xxx;
21、授权表空间给用户
grant unlimited tablespace to 用户名;
22、一个完整的过程,创建用户、创建表空间、授权、建表
创建用户
create user scott identified by tiger;
创建表空间
create tablespace scott_tablespace datafile ' D:\oraclexe\app\oracle\oradata\XE\scott.DBF' size 50m;
将表空间分配给用户
alter user scott default tablespace scott_tablespace;
给用户授权
grant create session, create table, unlimited tablespace,create sequence,create view,create indextype,create proceduer,create trigger to scott;
以 scott 登陆建立表
create table t_table(id number(10));
23、导入和导出命令 imp、exp
export
exp scott/tiger file=C:\EMP.DMF tables=e mp,dept,salgrade
import
imp scott/tiger file=C:\EMP.DMF