Oracle基础总结

1.概念类知识---略

2.创建用户:create user ll identified by test; ---用户名【ll】、密码【test】

dafault tablespace users     ---默认表空间users

temporary tablespace temp;  ---临时表空间temp

3.为用户分权限:grant connect,resource,dba to ll;---典型连接,开发,系统管理员权限

4.收回用户权限:revoke connect from ll;

5.创建学生表表空间为users,并指定主码为学号:

create table student(

               sno number(10),

               sname varchar(20),

               sex varchar(20),

               constraint  PK_SNO primay key(sno)

) tablespace uesrs;

6.alter方式指定主码外码:

主:alter table student add constraint PK_SNO primary  key(sno);

alter table student add constraint FK_SNAME foreign key (sname) references course(sname);

7.重命名表名和表列:

alter table sudent rename to s_student;

alter table student rename column age to age1;

8.创建视图:

create or replace view student(sno,sname,age) as select sno,sname,age from table student;

9.创建索引:

create index i_student on student (sno,sname,age);

10.创建序列:

create sequence stu

start with 1000,   --从1000开始

increment  by 2, --每次加2

maxvalue 2000,  --最大值

minvalue 1000, --最小值

nocycle, --不循环

nocache  --不缓存

11.删除数据的两种方式:

1.delete  from table **  ---记录重做消息,删除后不释放表空间,速度慢

2.truncate table  **---数据直接删除且释放表空间,不急日志,速度快

12.常用函数:

1.nvl(comm,0) --若comm为空,则显示0

2.查询前三行:

where rownum<=3

3.escape 关键字,例 select * from t11 where name like '%\_%' escape '\';

4.一般涉及到时间:to_date(),to_char()

5.round 四舍五入

6.、months_between(date1,date2)  --date1和date2之间有几个月

7.last_day(hiredate) -- 各月最后一天受雇人

8.add_months(x1,x2) --x1+x2月

9.decode函数

例:数据库中age1 ,显示男,age2 ,显示女

decode(age,1,男,2,女);

10.replace函数

例将名字中的洪全改为红

update student set sname=replace(sname,'洪','红')

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值