上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 21 下一页
摘要: 使用约束可以更好的保证数据库中的数据的完整性。约束的分类:1,主键约束主键表示是一个唯一的标识,本身不能为空alter table person add constraint PK_pid primary key(pid);2,唯一约束在一个表中只允许建立一个主键约束,而其他列如果不希望出现重复的话,则就可以使用唯一约束alter table person add constraint UK_name unique(name);3,检查约束检查一个列的内容是否合法alter table person add constraint CK_sex check(sex in('男','女'));al 阅读全文
posted @ 2011-02-07 23:02 魔战 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 一,常用的数据类型varchar/varchar2:表示的是一个字符串,有长度限制,为255number:number(n)表示一个整数,数字的长度是n,可以使用int;number(m,n)表示一个小数,数字小数长度为n,整数长度为m-n,可以使用floatdate:表示日期类型,日期要按照标准的日期格式进行存放clob:大对象,表示大文本数据,一般可以存放4g的文本blob:大对象,表示二进制数据,最大可以存放4g,例如:存放电影,歌曲,图片二,表的建立create table 表名称(字段名称1 字段类型[default 默认值],字段名称2字段类型[default 默认值],字段名称3 阅读全文
posted @ 2011-02-06 23:56 魔战 阅读(183) 评论(0) 推荐(0) 编辑
摘要: //创建表emp10create table emp10 as select * from emp where deptno=10;//删除行delete from emp10 where empno=7782;事物处理:保证数据操作的完整性,所有的操作要么同时成功,要么同时失败。在oracle中对于每一个连接到数据库的窗口(sqlplus,sqlplusw)连接之后实际上都会与数据库的连接建立一个session,即每一个连接到数据库上的用户都表示创建一个session。一个session对数据库所做的修改,不会立刻反映到数据库的真实数据之上,是允许回滚的,当一个session提交所有的操作之 阅读全文
posted @ 2011-02-06 22:58 魔战 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 一,子查询子查询:在一个查询的内部还包括另外一个查询select * from emp where sal(select sal from emp where empno=7654);单列子查询:返回的结果是一列的一个内容单行子查询:返回多个列,有可能是一条完整的记录多行子查询:返回多条记录select * from emp where sal(select sal from emp where empno=7654) and job=(select job from emp where empno=7788);select * from emp where sal=(select min 阅读全文
posted @ 2011-02-06 22:35 魔战 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 一,组函数count():求出全部的记录数max():求出一组中的最大值min():求出最小值avg():求出平均值sum():求和select count(*) from emp;select max(sal) from emp;select min(sal) from emp;select sum(sal) from emp;select avg(sal) from emp;二,分组统计select deptno,count(empno) from emp group by deptno;select deptno,round(avg(sal),2) from emp group by d 阅读全文
posted @ 2011-02-06 21:38 魔战 阅读(446) 评论(0) 推荐(0) 编辑
摘要: //查询表中的记录数select count(*) from emp;select e.empno,e.ename,d.deptno,d.dname,d.loc from emp e,dept d where e.deptno=d.deptno;select e.ename,e.sal,d.dname,s.grade from emp e,dept d,salgrade s where e.deptno=d.deptno and e.sal between s.losal and s.hisal;select e.ename,e.sal,d.dname,decode(s.grade, 阅读全文
posted @ 2011-02-06 14:20 魔战 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 一,基本操作语句select * from emp where comm is not null;select * from emp where not (sal1500 and comm is not null);select * from emp where sal between 1500 and 3000;//日期要加单引号select * from emp where hiredate between '1-1月 -81' and '31-12月 -81';在Oracle中区分大小写//in用在数字范围上select * from emp where sal in( 1300,14 阅读全文
posted @ 2011-02-05 23:17 魔战 阅读(403) 评论(0) 推荐(0) 编辑
摘要: sql功能强大,可以分成以下几组:1,DML(数据库操作语句):用于检索或者修改数据2,DDL(数据定义语言):用于定义数据的结构,如创建,修改或者删除数据库对象3,DCL(数据控制语言):用于定义数据库用户的权限一,给列取别名select empno 编号,ename 姓名,job 工作 from emp;二,消除查询列的重复项distinctselect distinct job 工作 from emp;三,使用oracle中提供的字符串连接操作“||”表示,如果要加入一些显示信息的话,所有的其他的固定信息要使用"‘"括起来。select '编号:'||empno||'的雇员,姓名是:'| 阅读全文
posted @ 2011-02-05 20:42 魔战 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 一,ed命令在sqlplusw中无法修改输入的字符,所以使用ed命令在记事本上进行编辑。命令格式:ed 文件名称在记事本中进行编辑命令,然后在sqlplusw中是用@文件名的方式执行命令,如果要修改记事本中的命令,则同样使用ed命令调用记事本文件。还可以在磁盘上建立一个记事本文件,然后再sqlplusw中输入@路径来执行指定文件的路径,如果文件的后缀名称是"*.sql"的话,则不用输入后缀名称也可以找到。二,在sqlplusw中也可以使用其他用户连接假设连接sys或system用户如果连接的是超级管理员(sys):则在连接的最后必须写上AS SYSDBA,以系统管理员的身份进行登录,conn 阅读全文
posted @ 2011-02-05 20:06 魔战 阅读(621) 评论(0) 推荐(0) 编辑
摘要: 图一:图二:图三:设置oracle安装目录,然后默认安装图四:选择创建数据库图5:填写全局数据库名,并且选择创建带样本方案的数据库选项图六:将所有的用户统一设置为admin图七:点击口令管理,进行用户解锁,scott,密码tiger;system,密码manager;sys,密码change_on_install最后确定完成。打开oracle服务表示监听服务,如果客户端要想连接到数据库,此服务必须打开。表示数据库的主服务,命名规则:OracleService数据库名称,此服务必须启动,否则Oracle无法使用。使用oracle可以在命令行下使用sqlplus命令,进入命令编辑区域,或者在开始- 阅读全文
posted @ 2011-02-05 19:28 魔战 阅读(469) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 21 下一页