oracle基础
一、Oracle安装1.windows10安装oracle将Oracle的两个压缩包解压到同一个文件夹下,点击setup.exe进行安装,如果安装过程中出现系统环境不匹配的情况,则找到文件cvu_prereq.xml,在D:oracle_softwaredatabasestagecvu路径下,添加以下内容: 1 <OPERATING_SYSTEM RELEASE="6.2"> 2 <VERSION VALUE="3"/> 3 <ARCHITECTURE VALUE="64-bit"/> 4 <NAME VALUE="Windows 10"/> 5 <ENV_VAR_LIST> 6 <ENV_VAR NAME="PATH" MAX_LENGTH="1023" /> 7 </ENV_VAR_LIST> 8 </OPERATING_SYSTEM> 正常安装后可以用oracle自带的sqlplus进行测试是否安装成功。 常见的Oracle命令:alter user [user] account unlock; ?? alter user [user] identified by [pwd]------------解锁用户并给该用户设置密码。 2.oracle的常见术语数据文件对应物理上的结构,表空间对应逻辑上的结构,日志文件记录着数据库的操作。 控制文件是二进制文件,维护着数据库的全局物理结构,支持数据库的启动和运行,数据在使用过程中不断的更新着控制文件。 二、Oracle与Sql1.DCL(数据控制语言)事务控制:rollback,commit和savepoint 权限控制:grant和revoke 新建用户后,一般都会赋予connect和resource权限,才能进行连接操作。 grant connect,resource to user; 2.DDL(数据定义语言) create语句:可以创建数据库和数据库的一些对象。 oracle 创建一个用户并指定默认表空间和临时表空间 1.创建临时表空间 权限传递,用户test1,test2,赋予test1权限,那么test1就可以将得到的权限赋予给test2 create user test1 identified by test1; create user test2 identified by test2; connect / as sysdba; grant connect,resource to test1 with admin option; connect test1/test1; 删除用户并且连用户的表空间一起删除 SQL> drop user test cascade; User dropped ? 3.DML(数据操纵语言)1.insert语句1 --复制表 2 create table student_copy as select * from student; 3 --修改表中的数据 4 update student_copy set sno=3 where sno=1; 5 update student_copy set sno=4 where sno=2; 6 --整个记录的每一列都插入 7 insert into student select * from student_copy where sno=3; 8 --插入记录的指定列 9 insert into student (sno,sname) select sno,sname from student_copy where sno=4; ? 2.update语句:1 --更新指定列 2 update student set sname=‘xiaoming‘,age=‘20‘ where sno=4; 3 4 --使用子查询进行更新 5 update student set (sname,age) =(select sname,age from student_copy where sno=3) where sno=4; 6 update student set sname=(select sname from student_copy where sno=3),age=(select age from student_copy where sno=4) where sno=3; 7 update student set sname=(select sname from student_copy where sno=3),age=(select age from student_copy where sno=4); 3.delete语句:1 --删除指定行数据 2 delete from student where sno=4; 3 --删除名称为abc的行数据 4 delete from student where sname=‘abc‘ 5 --删除全部数据 6 delete from student; 7 8 --使用子查询的删除 9 delete from student where sname=(select sname from student_copy where sno=3); 10 delete from student where sname in (select sname from student_copy); 4.DQL(数据查询语言)数据查询语言有单表查询 ,单表子查询, 多表查询,另写一篇博客详细写。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |