oracle数据库常用语句.pdf

oracle数据库常用语句.pdf

ID:57307217

大小:110.29 KB

页数:12页

时间:2020-08-11

oracle数据库常用语句.pdf_第1页
oracle数据库常用语句.pdf_第2页
oracle数据库常用语句.pdf_第3页
oracle数据库常用语句.pdf_第4页
oracle数据库常用语句.pdf_第5页
资源描述:

《oracle数据库常用语句.pdf》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、数据类型:字符类型:char(标准通用拉丁字符),nchar(汉字等其他字符),varchar2(长度可变字符),nvarchar2,long;数字类型:number(通用),integer,float日期和时间:date,timestamps(分秒,时区)行:rowid(逻辑地址),urowid(逻辑地址,内存地址);二进制:raw(size)(原始二进制数据),longraw,blob(二进制大型对象;最大4G字节),clob(字符大型对象),nclob,bfile;2.oracleWEB管理页面:localhost:556

2、0/isqlplus;localhost:5500/em3.net设置远程测试:tnspingdatebasename;远程连接:sqlplusname/password@datebasename;4.创建表空间:createtablespacetestdatafile'test.dbf'size10mautoextendonnext2mmaxsizeunlimitedloggingpermanentextentmanagementlocalautoallocateblocksize8ksegmentspacemanagemen

3、tmanuaL;//段空间5.创建用户并连接:createuser"TEST"identifiedby"TEST"defaulttablespaceTESTtemporarytablespaceTEMPquotaunlimitedonTESTquotaunlimitedonTEMPgrant"connect"totest//分配基本权限。conntest/test;6.重设用户密码:scott/tiger为默认用户,alteruserscottidentifiedbytiger;解锁:alteruserscottaccountu

4、nlock;7.sql脚本的执行:@路径/filename.sql;8.创建表:createtablet1(c1type约束,c2type约束(notnull,unique,check,primarykey))9.查询:selectdistinctc1fromt1where条件groupbyc1havingby子条件orderbyc1;10.连接字符串:selectc1(as可省)列1

5、

6、c2fromt1;11.单行函数:selectlower(c1)fromt1;upper全大写,initcap第一个字母大写,length;1

7、2.SelectSysdatefromdual(系统默认的空表)显示系统时间,months_between(date,date);13.round(数据,5位数),to_date(1997-10-11,’yyyy-mm-dd’),to_char()函数使用要转换。14.nvl(c1,0)把字段为空的值换为0,nvl2(c1,1,0)不空的为1,空的值为0;15.操作符:比较:=,<>,>=,<=,>,<;逻辑:and,or,not其他:in/notin,between..and..,isnull/isnotnull,like,e

8、xists/notexists;Eg:selectcount(distinctc1)as种类fromt1wherec1like‘%l%’(模糊查询如m_n)(c1between10and100)groupbyc1orderbyc1desc,c2desc(不写就默认asc)16.聚合函数:count(*)返回所有行的记录数,min(c1),max(c1),sum(c1),avg(c1);Eg:selectc1,count(*)fromt1groupbyc1havingbycount(*)>1;(having不能用变量申明);等价于

9、selectc1,count(*)ascnfromt1groupbyc1wherecn>1;17.声明主键和check:一.createtablet1(c1primarykey)二.创建表的时候指定限制的名称:createtablet1(c1constraintpk_empprimarykey);三:createtablet1(emp_nonumbernotnull,constraintpk_empprimarykey(emp_no));为已经存在的表增加主键:altertablet1addconstraintpk_emp2pr

10、imarykey(c1);创建check:createtablet1(budgetnumber(7),constraintCHK_PROJcheck(budget>10000andbudget<1000000))18.创建外键:createtablet1(dep

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

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

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