1. 创建用户语句:create user username
identified by password
2. 在sqlplus中切换用户语句:conn username/password
3. 在scott中为用户chen添加权限 :grant connect,resource to chen;
为这个用户添加某一个表的所有权限
Grant all on 表名 to 用户名
4. 修改用户的密码:alter user chen identified by newpwd;
5. 删除用户:drop user chen cascade;
6. 创建表的语句:
Create table teacher
(teacher_id number primary key;
Name varchar2(10);
Zhicheng varchar2(20);
Zhiwu varchar2(20)
)
7. orancle中两个伪列:rowid和rownum。
--用rowid删除掉那些重复的数据
delete 表名 where rowid not in(select max(rowid) from 表名 group by 属性1,属性2);
例:
delete emp where rowid not in(select max(rowid) from emp group by empid,empname);
--使用ruwnum查询出分页信息来,假设一页要查询出5个数据。
select * from (select e.*,rownum rn from 表名 e) where rn>5(n-1) and rn<5n+1;
例:
select * from (select e.*,rownum rn from emp e)where rn>0 and rn<6;
8. 事务控制语言包含的三个命令:commit,savepoint,rollback.
9. 撤销用户的权限:revoke all on student from chen;
10. 在查询的时候,使用“||”可以可以连接字段。
11. Orancle中的函数:
字符函数:initchar() ,首字母大写。
Lower(), 替换成小写.
数字函数:
Abs(); 取绝对值。
Ceil():向上取整。
Floor();向下取整。
Mod();取余数。
Round();四舍五入。
转换函数:
To_char();将日期或者是数字转换成字符串。
To_date();将字符转换成日期。
To_number();将字符转换成数字。
12. 行级锁会在insert,update,delete,select....for update设计到的行上添加。一旦执行这些语句,但是没有提交那么其他的用户不能操作这些行,只能等待。
13. 当想要操作的呢个行有用户正在进行增删改等操作时,那么我们可以设置用户等待的时间。例:
Select * from emp where empno=7639 for update wait 5;
这样用户就会只等待5秒,而不会无休止的等待下去。