Oracle 常用命令
一 管理用户
1 查询用户集合
select username from dba_users;
A 查询某个用户是否存在
select username from dba_users where username='用户名'
2 查询用户权限
select * from dba_sys_privs where grantee='用户名'
3 创建用户
create user 用户名 identified by 密码;
4 删除用户
drop user wp cascade;
5 切换用户
A conn / as sysdba //切换管理员
b conn 用户名/密码 //切换普通用户
6 细分授予权限
A grant create session to wp;//授权登入权限
B grant unlimited tablespace to wp;//授予zhangsan用户使用表空间的权限
C grant create table to wp;//授予创建表的权限
D grante drop any table to wp;//授予删除表的权限
E grant create sequence,select any sequence to 用户//授予 用户查询和创建序列的权限
7 给用户授予全部权限
A grant
create session, create any table, create any view ,create any index, create any procedure,
alter any table, alter any procedure,
drop any table, drop any view, drop any index, drop any procedure,
select any table, insert any table, update any table, delete any table
to wp;
B grant all to wp;
8 用户之间表访问的权限授予
A grant select on tablename to zhangsan;//授予zhangsan用户查看指定表的权限
B grant drop on tablename to zhangsan;//授予删除表的权限
C grant insert on tablename to zhangsan;//授予插入的权限
D grant update on tablename to zhangsan;//授予修改表的权限
E grant insert(id) on tablename to zhangsan;
F grant update(id) on tablename to zhangsan;//授予对指定表特定字段的插入和修改权限,注意,只能是insert和update
G grant alert all table to zhangsan;//授予zhangsan用户alert任意表的权限
9 取消用户权限
A revoke delete any table from wp;//取消用户删除权限,其他于此类似
B revoke
create session, create any table, create any view ,create any index, create any procedure,
alter any table, alter any procedure,
drop any table, drop any view, drop any index, drop any procedure,
select any table, insert any table, update any table, delete any table
from wp; 二 管理表
1 创建表
create table 表名;
A 主键 primary key
C 设置约束 constraint
2 删除表
drop table 表名
3 修改表名
rename 原表名 to 新表名
4 查询表结构
DESC 表名
5 清除表数据
delete from 表名
6 清空删除表
PURGE recyclebin;
7 彻底删除表
drop table 表名 purge 三 字段操作
1 增加字段
A 增加单字段
alter table 表名 add 字段名 数据类型;
B 增加多字段
alter table demo1 add(字段名 数据类型, ......依此类推);
2 删除字段
alter table 表名 drop column 字段名;
3 修改字段名称
ALTER TABLE 表名 RENAME COLUMN 旧字段名 TO 新字段名;
4 修改字段类型
ALTER TABLE 表名 MODIFY 字段名 新字段类型; 四 注释
1 查询表注释
select comments from user_tab_comments where table_name='表名';//需要注意的是表名需要大写,相应的还有dba_tab_comments,all_tab_comments,这两个比user_tab_comments多了ower列。
2 增加表注释
comment on table demo1 is 注释;
3 查询表字段注释
SELECT TABLE_NAME,COLUMN_NAME,COMMENTS FROM USER_COL_COMMENTS WHERE TABLE_NAME = '表名';//需要注意的是表名需要大写
4 增加字段注释
comment on column 表名.列名 is '注释'; 五 序列
1 查询用户序列
select sequence_name,sequence_owner from ALL_SEQUENCES where sequence_owner='用户名';//注意用户名得大写
2 增加序列
create sequence demo1_seq minvalue 最小值 maxvalue 最大值 start with 1 increment by 1 cache 10;
3 查询序列
select * from ALL_SEQUENCES where sequence_name='序列名';//注意序列名需要大写
4 删除序列
drop sequence DEMO1_SEQ;
5 或许序列值
序列名.nextval 六 触发器
1 查询触发器
2 增加触发器
3 删除触发器
Oracle 常用命令的更多相关文章
- Oracle常用命令1
一. 安装是用户管理: sqlplus /nolog; connect /as sysdba; alter user sys identified by change_on_install; alte ...
- oracle常用命令总结
声明:本文为博主在做项目中用到的一些常用命令,请勿转载,只为保存. oracle常用命令总结 创建表空间: --create tablespace vms--datafile 'e:\vms.dbf' ...
- oracle常用命令【转载】
oracle常用命令 一.Oracle数据库实例.用户.目录及session会话查看: 1.ORACLE SID查看设置 查看SID.用户名 $ env|grep SID .select * from ...
- Data Base Oracle 常用命令
Data Base Oracle 常用命令 1.登录:(不需要密码,属于管理员权限) conn /as sysdba; 2.查看数据库存储位置: select name from v$datafil ...
- oracle常用命令(1)
oracle常用命令 一.登录 1.管理员身份登录:sqlplus/nolog--->conn/as sysdba 2.普通用户登录:sqlplus/nolog---->conn 用户名/ ...
- Oracle常用命令大全(很有用,做笔记)
一.ORACLE的启动和关闭 1.在单机环境下 要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下 su - oracle a.启动ORACLE系统 oracle>svrmgrl ...
- oracle常用命令(比较常见好用)
一.ORACLE的启动和关闭 1.在单机环境下 要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下 su - oracle a.启动ORACLE系统 oracle>svrmgr ...
- linux下 oracle常用命令
打开图形化窗口: 1)Database Configuration Assistant windows (添加数据库实例) $ dbca 2)Oracle Net Configuration A ...
- 收集整理的oracle常用命令大全
一.Oracle的启动和关闭 1.在单机环境下 要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下 su - oracle a.启动ORACLE系统 oracle>svrmgrl ...
- Oracle常用命令大全
一.ORACLE的启动和关闭 1.在单机环境下 要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下 su - oracle a.启动ORACLE系统 oracle>svrmgrl ...
随机推荐
- 4K Block Size的Device和 Aligned IO
http://www.cnblogs.com/cenalulu/p/3587006.html 背景:最近采购了一批新的服务器,底层的存储设备的默认physical sector size从原有的 ...
- ROC和AUC介绍以及如何计算AUC
原文:http://alexkong.net/2013/06/introduction-to-auc-and-roc/ 为什么使用ROC曲线 既然已经这么多评价标准,为什么还要使用ROC和AUC呢?因 ...
- HttpServer的使用
http://docs.oracle.com/javase/8/docs/jre/api/net/httpserver/spec/overview-summary.html 1.Package com ...
- 炼数成金hadoop视频干货02
视频地址:http://pan.baidu.com/s/1dDEgKwD 这个视频理论性太强,不过倒是给了自己唯一的选项就是自己实践,不用像以前那样视频中敲一个字符,我也敲一个字符 讲到的内容: 介绍 ...
- 12096 - The SetStack Computer UVA
Background from Wikipedia: \Set theory is a branch of mathematics created principally by the German ...
- Rating
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission ...
- Android进阶笔记08:Android 中Activity、Window和View之间的关系
1. Android 中Activity.Window和View之间的关系(比喻): Activity像一个工匠(控制单元),Window像窗户(承载模型),View像窗花(显示视图) LayoutI ...
- ie6双边距bug及其解决办法
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Github 的一些基本操作
1.创建一个新的repository: 先在github上创建并写好相关名字,描述.例如这样一个地址: https://github.com/test/test2.git 回到本地目录如hellowo ...
- Log4Net(三)之记录日志到数据库
前面两篇短文向大家介绍了如何使用log4net,以及如何将log4net记录到文本文件中.下面本文将向大家介绍如何将log4net记录到数据库中. 经过前面的介绍,我想大家对使用log4net的过程已 ...