大型数据库理与应用实训王扬扬.doc

大型数据库理与应用实训王扬扬.doc

ID:55792524

大小:1.02 MB

页数:42页

时间:2020-06-02

大型数据库理与应用实训王扬扬.doc_第1页
大型数据库理与应用实训王扬扬.doc_第2页
大型数据库理与应用实训王扬扬.doc_第3页
大型数据库理与应用实训王扬扬.doc_第4页
大型数据库理与应用实训王扬扬.doc_第5页
资源描述:

《大型数据库理与应用实训王扬扬.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、1、建立一个表空间,表空间名为oracle_data,数据文件名为oracle.dbf,大小为20m,存在D盘根下createtablespaceoracle_datadatafile'd:oracle.dbf'size20Mextentmanagementlocal;2、建立一个用户,用户名是xuesheng,密码是xuesheng,用户表空间为oracle_dataCREATEUSERxueshengIDENTIFIEDBYxueshengDEFAULTTABLESPACEoracle_data;3、将dba的权限赋给xuesheng用户GRANTDBATOxuesheng;问题:如

2、何将dba的权限的sql语句解决方法:上网查3、将所给shixun.dmp文件存在D盘根目录下,用学生用户导入该文件D:>impuserid=xuesheng/xueshengfull=yfile=shixun.dmp问题;ORA-01658:无法为表空间ORACLE_DATA中的段创建INITIAL区解决方法:扩展表空间alterdatabasedatafile'd:oracle.dbf'resize800m;3、以xuesheng用户连接数据库,建立一个表,表结构如下:表名:student字段:idnumberNamevarchar2(2);Agevarchar2(2)要求1)将i

3、d设置成为自动增长列(用序列、触发器)2)向表中插入记录:李明23王勇22刘江飞19建表studentcreatetablestudent(idnumbernotnullprimarykey,Namevarchar2(2)notnull,Agevarchar2(2)notnull);创建序列createsequencestudent1incrementby1startwith1nomaxvaluenocycle;创建触发器createorreplacetriggerstudent2beforeinsertonstudentforeachrowbeginselectstudent1.next

4、valinto:new.idfromdual;end;/改变表Name的数据类型altertablestudentmodifynamevarchar2(10);插入数据insertintostudent(Name,Age)values('李明','23');insertintostudent(Name,Age)values('王勇','22');insertintostudent(Name,Age)values('刘江飞','19');问题:插入的值对于列过大解决:改变表Name的数据类型altertablestudentmodifynamevarchar2(10);6、首先为studen

5、t表增加2列:score(用于存放百分制成绩),grade(用于存放5分制ABCDE成绩),并依次为每个人录入92,88,75的百分制成绩增加列altertablestudentaddscorenumbercheck(scorebetween0and100);altertablestudentaddgradevarchar2(3);添加数据updatestudentsetscore=92whereid=1;updatestudentsetscore=88whereid=2;updatestudentsetscore=75whereid=3;7、阅读以下语句,分析其实现了什么功能:updat

6、estudent  setgrade=(  selectgradefrom  (  selectid,  casewhenscore>90then'a'  whenscore>80then'b'  whenscore>70then'c'  else'd'endgrade  fromstudent  )a  wherea.id=student.id  );看能不能对上述语句进行优化/简化?功能:根据id的值来更改student表中grade列的值,当score的值大于90小于等于100时输出a,当score的值大于80时,输出b,当score的值大于70时,输出c,其他时候输出d。优化后up

7、datestudent  setgrade=(  selectgradefrom  (  selectid,  casewhenscorebetween90and100then'a'  whenscorebetween80and89then'b'  whenscorebetween70and79then'c'whenscorebetween60and69then'd'  else'e'endgrade  fromstud

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。