--创建用户

create user zzg identified by zzg123;

--修改用户的密码

alter user zzg identified by unis;

--所有用户所在的表空间

select username,default_tablespace from dba_users;

--创建一个表空间.

create tablespace ts_zzg datafile 'f:\ts_zzg\zzg_data.dbf' size 200M;

--查询已创建的表空间

select * from DBA_DATA_FILES;

--用户分配权限

grant create session,create table,create view,create sequence,unlimited tablespace to zzg;

--查询用户所具有的权限

select *from session_privs;

--查看用户和默认表空间的关系

select username,default_tablespace from dba_users;

--查看当前用户能访问的表

select * from user_tables;

--Oracle查询用户表

select * from user_all_tables;

--Oracle查询用户视图

select * from user_views;

--查询所有函数和储存过程:

select * from user_source;

--查询所有用户:

select * from all_users;

--select * from dba_users

--查看当前用户连接:

select * from v$Session;

--查看用户角色

SELECT * FROM USER_ROLE_PRIVS;

--查看当前用户权限:

select * from session_privs;

--查看所有用户所拥有的角色

SELECT * FROM DBA_ROLE_PRIVS;

--查看所有角色

select * from dba_roles;

--查看数据库名

SELECT NAME FROM V$DATABASE;

--查看所有表空间使用情况

select a.file_id "FileNo",

a.tablespace_name "Tablespace_name",

a.bytes "Bytes",

a.bytes - sum(nvl(b.bytes, 0)) "Used",

sum(nvl(b.bytes, 0)) "Free",

sum(nvl(b.bytes, 0)) / a.bytes * 100 "%free"

from dba_data_files a, dba_free_space b

where a.file_id = b.file_id(+)

group by a.tablespace_name, a.file_id, a.bytes

order by a.tablespace_name;

Oracle 创建普通用户,并赋予权限

采用sys or system / manager as sysdba; 连接数据库。

--创建普通用户konglin:

create user konglin identified by pwd_oracle;

--删除用户,

drop user konglin;

--授予用户登录数据库的权限:

grant create session to konglin;

--授予用户操作表空间的权限:

grant unlimited tablespace to konglin;

grant create tablespace to konglin;

grant alter tablespace to konglin;

grant drop tablespace to konglin;

grant manage tablespace to konglin;

--授予用户操作表的权限:

grant create table to konglin; (包含有create index权限, alter table, drop table权限)

--授予用户操作视图的权限:

grant create view to konglin; (包含有alter view, drop view权限)

--授予用户操作触发器的权限:

grant create trigger to konglin; (包含有alter trigger, drop trigger权限)

--授予用户操作存储过程的权限:

grant create procedure to konglin;(包含有alter procedure, drop procedure 和function 以及 package权限)

--授予用户操作序列的权限:

grant create sequence to konglin; (包含有创建、修改、删除以及选择序列)

--授予用户回退段权限:

grant create rollback segment to konglin;

grant alter rollback segment to konglin;

grant drop rollback segment to konglin;

--授予用户同义词权限:

grant create synonym to konglin;(包含drop synonym权限)

grant create public synonym to konglin;

grant drop public synonym to konglin;

--授予用户关于用户的权限:

grant create user to konglin;

grant alter user to konglin;

grant become user to konglin;

grant drop user to konglin;

--授予用户关于角色的权限:

grant create role to konglin;

--授予用户操作概要文件的权限

grant create profile to konglin;

grant alter profile to konglin;

grant drop profile to konglin;

--允许从sys用户所拥有的数据字典表中进行选择

grant select any dictionary to konglin;

--查看所有用户:

select * from dba_users;

select * from all_users;

select * from user_users;

--查看用户或角色系统权限(直接赋值给用户或角色的系统权限):

select * from dba_sys_privs;

select * from user_sys_privs;

--查看角色(只能查看登陆用户拥有的角色)所包含的权限

sql>select * from role_sys_privs;

--查看用户对象权限:

select * from dba_tab_privs;

select * from all_tab_privs;

select * from user_tab_privs;

--查看所有角色:

select * from dba_roles;

--查看用户或角色所拥有的角色:

select * from dba_role_privs;

select * from user_role_privs;

--查看哪些用户有sysdba或sysoper系统权限(查询时需要相应权限)

select * from V$PWFILE_USERS

比如我要查看用户 wzsb的拥有的权限:

SQL> select * from dba_sys_privs where grantee='WZSB';

--比如我要查看用户 wzsb的拥有的角色:

SQL> select * from dba_role_privs where grantee='WZSB';

--查看一个用户所有的权限及角色

select privilege from dba_sys_privs where grantee='WZSB' union select privilege from dba_sys_privs where grantee in (select granted_role from dba_role_privs where grantee='WZSB' );

--创建表--student表

create table student(

  stu_id varchar2(10) primary key,

  stu_name varchar2(10) not null,

  stu_sex varchar2(2) not null,

  stu_birthday date,

  class_id number

)

--追加注释

--添加表注释

comment on table student is '学生信息表';

--字段添加注释

comment on column student.stu_id is '学号(主键)';

comment on column student.stu_name is '学生姓名';

comment on column student.stu_sex is '学生性别';

comment on column student.stu_birthday is '学生出生年月';

comment on column student.class_id is '学生所在班级';

Oracle 自定义函数

create [or replace] function function_name

  [(parameter_list)]

  return datatype

  {is/as}

  [local_declarations]

  begin

    executable_statements;

  [exception_handlers;]

  end;

  说明:

  function_name:函数名称。

  parameter_list:函数列表,可选。

  return datatype:指定函数的返回类型,不能指定大小。

  local_declarations:局部变量声明,可选。

  executable_statements:要执行的PL-SQL语句。

  exception_handlers:异常处理,可选。

  or repalce:是否覆盖,可选。

Oracle 相关查询的更多相关文章

  1. oracle 相关查询和非相关查询,oracle 去除重复数据,以及oracle的分页查询!

    一.oracle中的相关查询?和非相关查询? 二.oracle去除重复数据 1. 2. 3.oracle 实现分页? 利用rownum的唯一性,和子查询,将rownum从伪列变成实际列!

  2. Oracle子查询相关内容(包含TOP-N查询和分页查询)

    本节介绍Oracle子查询的相关内容: 实例用到的数据为oracle中scott用户下的emp员工表,dept部门表,数据如下: 一.子查询 1.概念:嵌入在一个查询中的另一个查询语句,也就是说一个查 ...

  3. Oracle权限相关查询

    Oracle权限相关查询着实视图有点多,记录下常用的语句,方便查询:1.查看所有用户:  select * from dba_users;  select * from all_users;  sel ...

  4. 工作中遇到的oracle分页查询问题及多表查询相关

    在工作中,有时,我们会用到oracle分页查询.这时,就需要先了解oracle的rownum.rowmun是oracle的伪列,只能用符号(<.<=.!=),而不能用这些符号(>,& ...

  5. 各种oracle参数查询语句

    各种oracle参数查询语句 1.show parameter:--显示各个系统参数配置 2.select * from v$parameter;--显示各个系统参数配置 2.show paramet ...

  6. Oracle树查询及相关函数

    Oracle树查询的最重要的就是select...start with... connect by ...prior 语法了.依托于该语法,我们可以将一个表形结构的中以树的顺序列出来.在下面列述了Or ...

  7. Oracle 去重查询

      Oracle 去重查询 CreateTime--2018年2月28日15:38:45 Author:Marydon (一)使用distinct --查询指定区间内表停诊字段的值 SELECT DI ...

  8. Oracle相关数据库操作

    1.进入oracle后台操作 su - oracle 2.数据库备份的指定位置 Oracle用sys用户登录查询数据库 select * from dba_directories a where a. ...

  9. Oracle树查询总结

    最近在做公司的项目中遇到一个问题,多级级联导航菜单,虽然只有三级目录,但<li>中嵌套<ul>,数据库表结构如下: CREATE TABLE FLFL ( ID NUMBER ...

随机推荐

  1. C++标准模板库(STL)和容器

    1.什么是标准模板库(STL)? (1)C++标准模板库与C++标准库的关系 C++标准模板库其实属于C++标准库的一部分,C++标准模板库主要是定义了标准模板的定义与声明,而这些模板主要都是 类模板 ...

  2. 【翻译】追溯“typeof null”的历史

    我的翻译小站:https://www.zcfy.cc/article/the-history-of-typeof-null 翻译原文链接:http://2ality.com/2013/10/typeo ...

  3. google-glog功能介绍

    google-glog功能介绍 分类: 其它类型2011-08-19 10:06 6618人阅读 评论(0) 收藏 举报 cookiesgooglestreammodulemapreducenull ...

  4. java线程一

    我们可以在计算机上运行各种计算机软件程序.每一个运行的程序可能包括多个独立运行的线程(Thread).线程(Thread)是一份独立运行的程序,有自己专用的运行栈.线程有可能和其他线程共享一些资源,比 ...

  5. go 编译问题

    golang的编译使用命令 go build , go install;除非仅写一个main函数,否则还是准备好目录结构:GOPATH=工程根目录:其下应创建src,pkg,bin目录,bin目录中用 ...

  6. MySql采用range分区可提升查询效率

    简介: RANGE分区基于一个给定的连续区间范围,早期版本RANGE主要是基于整数的分区.在5.7版本中DATE.DATETIME列也可以使用RANGE分区,同时在5.5以上的版本提供了基于非整形的R ...

  7. jquery.cookie.js 删除cookie

    简单交代一下背景:asp.net页面的上的切换登录按钮的点击事件实现cookie的删除. 但是好像没办法直接删除,通过网上提供的方法,可以使用jquery.cookie.js 来操作cookie的创建 ...

  8. C# 读取Excel,一波华丽的操作

    C# 读取Excel,其实有很多方法.但是今天要来一波华丽的操作. 先看效果: 以上这波操作使用了 ExcelDataReader 和 ExcelDataReader.DataSet 完成的. Exc ...

  9. SQL学习笔记1

    2018.10.15:周一   -- 返回前5个数据 SELECT TOP 5 * FROM Student;   -- 返回前50%的数据 SELECT TOP 50 PERCENT * FROM ...

  10. winform npoi excel 样式设置

    IWorkbook excel = new HSSFWorkbook();//创建.xls文件 ISheet sheet = excel.CreateSheet("sheet1") ...