Oracle学习笔记

发布 2021-05-11 23:24:28 阅读 9493

--破攻。连接命令:conn scott/000@oracle as sysdba/sysoper

1. passw scott [dba]

2. 文件操作:a. start d:\ 或 @ d:\ b. edit d:\

c. spool d:\ spool off)

3. 交互式命令:a. &select * from emp where job=’&job’

4. 显示和设置环境变量:a. show linesize b. set linesize 90 用法同上。

5. 用户管理:

a. 创建create user scott identified by m000 [dba]

b.改密:passw scott [dba] /alter user scott identified by 000

c.删除:drop user scott (cascade) [dba]

d.授权: connect/resource to scott (with admin option)

select/all/index/alter on to xiaoming (with grant option)

e.收回权限: revoke select/all on from xiaoming[谁授权谁收回] [系统权限**不是级联,对象权限是级联]

execute on dbms_transaction to scott; /执行包权限。

g.帐户锁定 profile xx limit failed_login_attempts 3 password_lock_time 2

2.终止口令create profile xx limit password_life_time 10 password_grace_time 2

profile password_life_time 10 password_grace_time 2 password_reuse_time 10 [10天后可以重用密码]

4.配置:alter user us profile xx 删除:drop profile xx (cascade)

h.解锁:alter user us account unlock

and sysoper

6.表的管理:a.

建表: create table student (xh number(4),xm varchar2(20),sex char(2),birthday date,sal number(7,2clob,timestamp,blob)

b.加字段:alter table student add ( classid number(2))

c.改字段:alter table student modify (xm varchar2(30))

d.该字段类型/名字:alter table student modify (xm char(30))

e.删字段:alter table student drop column sal

f.改表名:rename student to stu

g.删表:drop table student

h.加数据:insert into student values (…

i.改日期格式:alter session set nls_date_format = yyyy-mm-dd’ j.

插入部分字段: insert into student (xh,xm,sex) values (…空值用null]

k. 改字段:update student set sex=’女’,birthday =’1989-01-11’ where xh =’114空值用is null]

l.删除数据:delete from student (where xh=’114’)

m.删除结构:drop table student

n.删除不可找回:truncate table student;

o. to_date函数:insert into xxvalues(7788,to_date(‘1989-12-12’,’yyyy-mm-dd’))

p. 多行插入:insert into kkk (id,name,dept) select empno,ename,deptno from emp where deptno=10;

q. 多行修改:update emp set job=(select job from emp where ename=’smith’),sal=(select sal from emp where ename=’smithwhere ename=’smith’;

7.表的查询:a.结构:desc emp列:select ename,sal from emp where..

b.去重:select distinct deptno,job from emp

c.显示查询时间 set timing on

d.查询记录数:select count(*)from emp

e..表达式:select ename,sal*12 as “年工资” from emp

: 如果comm不存在就赋值为0

g.连接字符串select ename ||is a ’|job from emp

h.逻辑操作符: by : select sal*12 “年薪” from emp order by “年薪asc/desc;

2.函数:select max(sal),min(sal),**g(sal) from emp;

eg:select ename,sal from emp where sal=(select max(sal) from emp);

by: select **g(sal),max(sal),deptno,job from emp (order by deptno,jobh**ing **g(sal)>2000);

i.多表查询:

from emp a1,dept a2 where (and

eg:select from emp a1 ,salgrade a2 (where between and (order by dept);

2.自连接:select from emp worker,emp boss where (and

j.子查询:1. 单行:select * from emp where deptno=(select deptno from emp where ename=’smith)’;

2.多行:select * from emp where job in (select distinct job from emp where deptno=10);

:select ename,sal,deptno from emp where sal>all (select sal from emp where deptno=30);

4. 多列:select * from emp where (deptno,job)=(select deptno,job from emp where ename=’smith’);

from emp a2,

select deptno,**g(sal) mysal from emp group by deptno) a1

where and >

6.分页: a1.*,rownum rn from (select * from emp ) a1;

b. select * from (select a1.*,rownum rn from (select ename,sal from emp order by sal) a1 where rownum<=10) where rn>6;

7.用查询结果建新表:create table myt (id,name,sal,job) as select empno,ename,sal,job from emp;

k.合并查询:1.去重2.不去重3.取交集4.取差集:

select ename,sal,job from emp where sal>25000

( /all /3. intersect /4. minus)

select ename,sal,job from emp where job=’manager’;

中操作数据库:[分页项目]

用户名薪水。

connection ct = jdbc:odbc:oracle", scott", 000");

ORACLE学习笔记

rac real application clusters 真实应用集群。ohs oracle http server sga system global area 系统全局区,是系统为实例分配的一组共享缓冲存储区,用于存放数据库数据和控制信息,以实现对数据库数据的管理和操作。实例 存取和控制数据数...

Oracle学习笔记

参数文件 记录了控制文件的位置,控制文件是一个非常小的二进制文件,最大。可以增长到 64mb,控制文件包括如下主要信息 数据库的名字,检查点信息,数据库创建的时间戳 所有的数据文件,联机日志文件,归档日志文件信息 备份信息等 有了这些信息,oracle 就知道那些文件是数据文件,现在的重做日志文件是...

ORACLE学习笔记

目录。oracla管理 1 1.登录sqlplus 1 1.1.sysdba 身份登陆 1 1.2.普通用户登陆sqlplus 1 2.常用命令 1 3.格式化提示符 2 4.查看系统状态 2 4.1.查看实例状态 2 4.2.查看表 2 5.关闭 启动 2 6.创建表空间 3 7.用户和权限 3 ...