1.Oracle 的系统用户sys 是超级用户,具备sysdba权限,具备建立数据库的权限,默认密码为change_on_install。sql
而system为管理操做员,权限也很大,具备sysoper权限,可是没有create database的权限,默认密码为manager数据库
2. 在Oracle中表、视图、存储过程、序列、函数等等通称为数据对象。ide
3. cmd中输入sqlplusw 进入SQL*PLUS函数
修改本身的密码: passw 新密码命令行
显示当前用户: show user;对象
运行sql脚本: start d:\aaa.sqlcmd
编辑sql脚本文件: edit d:\aaa.sqlit
将屏幕中的数据输入到文件中:io
Spool bbb.sql;table
Select * from test;
Spool off ;
交互式命令: select * from test where name=’&name’; 会弹出一个窗口提示 输入一个name
显示和设置环境变量:
Linesize 为每行显示的长度 show linesize set linesize 50 默认为80
Pagesize 分页 set pagesize 12; 为打印一些报表服务的。
4.Dba权限的用户才能建立用户和修改用户密码,删除用户要具备drop user 的角色
Create user heshan identified by a123;
给其余用户修改密码: password heshan
删除用户:drop user heshan [cascade 级联删除表等数据库对象]
Grant 赋予权限 revoke 回收权限
新用户没有任何权限,没有登陆到数据库的权限 (角色是权限的集合)
Grant connect to heshan;
Grant resource to heshan 在表空间里面建表的权限便可以使用表空间
Grant select on test to heshan(拥有表的用户能够受权)
Grant select on test to heshan with grant option(赋权给heshan 使heshan还能够赋给其余用户 可是只能够为对象权限)
若是为系统权限
Grant connect to heshan with admin option;
当回收权限的时候,传递的权限会被回收掉。
帐户锁定:
Create profile lock_amount limit failed_login_attemps 3 password_lock_time 2;
(尝试三次 锁定2天)
Alert user heshan profile lock_amount;
Alert user heshan account unlock;
终止口令:
Create profile myprofile limit password_life_time 10 password_grace_time 2;
(10天提醒修改密码,宽限期两天)
Alert user heshan profile myprofile;
口令历史:
Create profile paasword_history limit password_life_time 10 password_grace_time 2 paasword_reuse_time 10;
(10天提醒修改密码,宽限期两天,10天之后的能够重用)
Drop profile myprofile;(删除口令文件)
5.表的管理
添加一个字段:
Alert table test add(name varchar(20));
Alert table test modified (name varchar(30));//修改表的字段长度
Alert table test drop column name; //删除表中一个字段
Rename test to test1;//修改表名
Set timing on;打开执行的时间
设置只读事物:set transaction read only;
Oracle在对数据处理的时候有隐性转换。
导出表:
Exp heshan/heshan123@orcl tables=(test) d:\aa.dmp //表数据
Exp heshan/heshan123@orcl tables=(test) d:\aa.dmp rows=n //表结构
数据字典:
Select tables from user_tables;(all_tables dba_tables)//查询用户全部的表
查询一个角色具备的权限
Select * from dba_sys_privs where grantee=’CONNECT’;
Select * from role_sys_privs where role=’CONNECT’;
查询某个用户具备的权限
Select * from dba_role_privs where grantee=’heshan’;
添加约束:
Alert table test add constraint testUnique unqique(id);
调用函数:
命令行模式:
Var abc number;
Call test(‘heshan’) into:abc;