设为首页 加入收藏

TOP

oracleocp知识点(一)
2015-11-21 01:38:49 来源: 作者: 【 】 浏览:0
Tags:oracleocp 知识点
1.如何确定 数据库是否启动
su - oracle
ps -ef |grep ora_|head -2
两种关系数据库是ora或者是自动存储管理的asm开头的,
查看进程可以知道数据库实例至少已经启动,但是数据库是否挂载,是否打开,不得而知
asm
crs_stat -t
updb.db online
sr vctl status database -d updb


db
sqlplus -s / as sysdba
select open_mode from database;
通过查询该视图可以知道数据库是否启动,该视图显示了数据的状态
asm
cat .asm
export ORACLE_HOME=/u01/grid/11g
export PATH=$ORACLE_HOME/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin
export ORACLE_SID=+ASM
grep asm .bashrc
alias asm=". ~/.asm"


cre_stop ora.updb.db
srvctl status/stop database -d updb
srvctl status/stop/start database -d updb -o


2.如何确定数据库实例名
ps -ef |grep ora_|head -1 |cut -d '_' -f3
sqlplus / as sysdba
select instance_name from v$instance;
后台进程和数据库查询两种方式
export ORACLE_SID=updb
echo $ORACLE_SID


source !$
. !$
oracle_sid在windows不区分大小写,但是其他 系统区分大小写
grep SID .db11g
ps -ef|grep ora_|cut -d '_' -f3|sort|uniq
多个实例,只需要通过export ORACLE_SID=updb切换
3.如何连接到sqlplus
[oracle@oracle ~]$ tail -l /etc/oratab
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
wyzc10g:/u01/oracle/10g:N
wyzc11g:/u01/oracle/11g:N # line added by Agent
wyzc:/u01/oracle/12c:N: # line added by Agent


export ORACLE_SID=wyzc10g
export ORACLE_HOME=/u01/oracle/10g
export PATH=
which sqlplus
sqlplus /nolog
解锁用户
show user
alter user scott indentified by tiger account unlock;
4.查看用户下有哪些表
select * from tab;
select table_name from user_tables;
5.如何查看表结构
set linesize 50
desc dept
6.select 语句的功能
列查询、行查询、多表查询
书写规则:
不区分大小写
可以分行书写
关键词不能简写或分割跨行
通常一个子句一行
双引号加起的语句必须区分大小写
sqldelevoper
/u01/oracle/11g/sqldevdloper/sqldeveloper.sh
7.默认列标题
sqlplus
字符型、日期靠左对齐
number 靠右对齐
开发工具
靠左
8.算数表达式
空值 defining a null value
null is value that is unavailable,unassigned,,unknown,or inapplicable
null is not the same as zero or a blank space
不能进行算数运算,否则为空
要进行算数运算,需要空值函数运算,nvl(字段,0)
9.别名
重命名列标题,有益于运算,直接跟在列名之后,as是可选的字符
包含空格、特殊字符、区分大小写使用""引起来
非法语句合法化,如下
create table e1 as select deptno,sum(sal) from emp group by deptno;执行此语句会提示错误
修改为create table e1 as select deptno,sum(sal) salcomm from emp group by deptno;
连接符:将列连接起来,最后的结果肯定为字符串 ||
字面字符:number,data,字符型,必须用单引号引起来
select 'name: '|| empno from emp
name; 7900
name: 7800
select ename || 'is work '|| job from emp;
两个单引号在一起表示一个单引号
select ename || '''is work '|| job from emp;
select ename||q'['s work ]'||job from emp;
此处的符号[]可以替换为任意的符号,但是必须成对出现
10.去除重复行
select distinct deptno from emp; 关键字 考试一般选择此项
select distinct(deptno) from emp; 函数
select unique deptno from emp; 关键字
select unique(deptno) from emp; 函数
11.限制行的查询
select * from emp where condtion(s);where子句必须放在from之后
select * from emp where empno='7900';
字符与日期使用单引号引起来
字符区分大小写,日期格式敏感
默认日期显示格式DD-MON—RR
比较操作符
=, >, <, >=, <=, <> ^= !=, in, like, between and, is null,
取反操作
select ename,sal from emp where sal not between 2000 and 3000;
select ename,sal from emp where not sal between 2000 and 3000;两次运算,效率低下
select ename,sal from emp where sal not in(2000,3000);
select ename,sal from emp where not sal in(2000,3000);运算两次,
select ename from emp where ename like '__A%';
select ename from emp where ename like 'A%';
select ename from emp where ename like '%S';
select ename from em
首页 上一页 1 2 3 4 5 下一页 尾页 1/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle服务器连接 下一篇Oracle性能分析7:创建索引

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: