oracle数据库基本操作

1.安装好oracle数据库后,默认有三个账号,如下:

a. sys 用户 最高管理权限

登陆方式:必须带上as sysoper 或者as sysdba :

例如:conn sys/123456 as sysoper ;conn sys/123456 as sysdba ;

用show user命令出现的为当前用户为“public”;

 

b.system 用户 dba

登陆方式:不必带上sysoper或者sysdba;

例如:conn system/123456 ; show user ,显示为:”system“;

conn system/123456 as sysdba ;show user ,显示为:”sys“;

 

C.scott 用户 普通用户,一般安装后,都会有该用户

登陆方式和上面一样,但是有时会发现,该用房呗lock了。需要为它解锁。

例如:ALTER USER scott ACCOUNT UNLOCK

具体参考:http://caihorse.iteye.com/blog/633793 ;

 

2.sysdba ,sysoper.normal ;

在使用plsql登陆数据库是,登陆界面需要用户选择登陆connect as ;通常就是这三种方式。下面是个人了解情况:

sys and system are "real schemas", there is a user SYS and a user SYSTEM.

In general, unless the documentation tells you, you will NEVER LOG IN as sys or system, they are our internal data dictionary accounts and not for your use. You will be best served by forgetting they exist.

sysdba and sysoper are ROLES - they are not users, not schemas. The SYSDBA role is like "root" on unix or "Administrator" on Windows. It sees all, can do all. Internally, if you connect as sysdba, your schema name will appear to be SYS.

In real life, you hardly EVER need sysdba - typically only during an upgrade or patch.

sysoper is another role, if you connect as sysoper, you'll be in a schema "public" and will only be able to do things granted to public AND start/stop the database. sysoper is something you should use to startup and shutdown. You'll use sysoper much more often than sysdba.

do not grant sysdba to anyone unless and until you have absolutely verified they have the NEED for sysdba - the same with sysoper.

具体参考:http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2659418700346202574

SYSDBA can do more than start/stop the database. It has a lot more functionality that sysoper (Operator mode) which is normally used for basic database functions such as start/stop.

SYSOPER privilege allows operations such as: Instance startup, mount & database open ;Instance shutdown, dismount & database close ;

Alter database BACKUP, ARCHIVE LOG, and RECOVER.This privilege allows the user to perform basic operational tasks without the ability to look at user data.

SYSDBA privilege includes all SYSOPER privileges plus full system privileges (with the ADMIN option), plus 'CREATE DATABASE' etc..This is effectively the same set of privileges available when previously connected INTERNAL.

具体参考:http://www.orafaq.com/maillist/oracle-l/2001/12/07/0435.htmv;

注:上面提到的角色的概念为:

 参考:http://liuyf8688.iteye.com/blog/39505

 

3.启动oracle数据库:打开服务,启动实例和监听器。

 

4.更改用户密码:password username

5.运行一个sql文件,例如存放在D:/test.sql ,运行为:start D:/test.sql;

6.spool 命令为截屏命令;使用为:

->spool D:/test.sql

->select * from stuentinfo;

->spool off

包select出来的东西报错到test.sql 文件中。

7.linesize
->show linesize
->set linesize
8.pagesize
->show pagesize
->set pagesize

 

9.创建用户,例如:

->create user luo indentified by system

10.删除用户,例如:

->drop user luo (自己删除自己是不允许的)

11.如果该用户下面已经有相关的表(对象,包括view等),需要用cascade (级联删除)关键字

12.新建的用户是没有权限的,只能用system或者sys两个超级用户分配权限,又叫分配角色给这个用户。

例如:

->grant connect to luo
把连接权限赋值给Luo

 

13.orcal事先定义了一些权限
大概分为几类,系统权限与对象权限;
系统权限指的是:用户对数据库访问的相关权限;对象权限,用户对其他用户的数据对象的访问权限

 

14.希望xiaoming用户可以去查询system用户下面的emp表

对象权限:insert update delete

->grant select on emp to xiaoming(授权)(system connected)
把 system中的emp表授权给小明,小明只有查询的功能

但是没有update或者delete的功能。

切换到小明的账户
->select * from system.emp(方案)(xiaoming connected)

希望小明对emp表的各种权限

->grant all on emp to xiaoming;(system connected)

收回某个权限(system 希望收回小明对emp的查询权限)

->revoke select on emp from xiaoming;(system connected)

 

15.对权限的维护
希望小明用户可以去查询system的emp表,同时希望小明可以把这种权限继续给别人

如果是对象权限
a.->grant select on emp to xiaoming with grant option;(system connected)

b.->conn system/123456
  ->create user xiaohong identified by m123

c.->grant connect to xiaohong

d.->conn xiaoming/m1234
e.->grant select on scott.emp to xiaohong ;

如果是系统权限
->grant connect to xiaoming with admin option

16.如果scott把小明对emp的查询权限revoke了,那么小红是否还有相应的权限呢。答案为被诛杀。
revoke select on emp from xiaoming;


17.创建profile文件
create profile lock_account limit failed_login_attcmpts 3 password_lock_time 2

转载于:https://www.cnblogs.com/blogsyuanjian/archive/2012/07/11/2586185.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值