oracle 命令收集

来源:互联网 发布:端口号范围 编辑:程序博客网 时间:2024/06/05 17:09
查看序列
select sequence_name from ALL_SEQUENCES;

select sequence_name from USER_SEQUENCES;

select sequence_name from DBA_SEQUENCES;

查看Oracle连接
select count(*) from v$process;
select value from v$parameter where name = 'processes';

select count(*) from V$PROCESS v$process;
select value from   V$PARAMETER v$parameter where name = 'processes';
select value from   V$PARAMETER  where name = 'processes';
更改连接数
alter system set processes=500 scope=spfile;
然后重新起服务

my oracle username:system  password:123456


打开sqlplus:sqlplus/nolog
进入system管理:conn system/你的密码
对scott进行解锁:alter user scott account unlock;

create user li_zhuo identified by li_zhuo
(创建了一个用户名:li_zhuo 密码 li_zhuo)

grant connect,resource,create view to li_zhuo;
为用户付权限


select *  from   dba_users;
查询所有用户

Select Count(*) From User_Tables //查看所有表

-----------------------------------导入表
cmd
exp system/manager@ocrl og=E:\table.log file=e:\\table.dmp

cmd
imp system/manager@ocrl   file=e:\table.dmp full=y


虚拟机IP 地址 90.10

查看休眠的表
select
'alter table '|| table_name ||' move;'
from user_tables where segment_created='NO';

单表备份
exp system/manager@ocrl file=E:\table.dmp log=E:\table.log tables=(table)  


exp system/manager@ORCL file=E:\数据备份\20140718.dmp full=y  log=E:\数据备份\20140718.log


imp system/manager@ocrl  file=e:\table.dmp log=E:\table.log   full=y


单表导入
imp system/manager@ocrl   file=e:\table.dmp  tables=(table) ignore=y  statistics=none



  -- Drop existing database link
drop database link GSDB;
-- Create database link
create database link GSDB
  connect to GLORYOU_JNGBS identified by "username~!"
  using 'SAASDBGS';

备份表
create table pla_user_07241625 as select * from  pla_user


创建序列

SELECT

 ' CREATE SEQUENCE '||SEQUENCE_NAME||
 ' MINVALUE '|| MIN_VALUE  ||
 ' MAXVALUE '|| MAX_VALUE  ||
 ' START WITH '||LAST_NUMBER||
 ' INCREMENT BY '|| INCREMENT_BY ||
 ' CACHE '|| 20 || ';'
 
 from USER_SEQUENCES


SELECT
 ' CREATE SEQUENCE '||SEQUENCE_NAME||
 ' INCREMENT BY '|| INCREMENT_BY ||
 ' START WITH '||LAST_NUMBER||
 ' MAXVALUE '|| MAX_VALUE  ||
 'MINVALUE '|| MIN_VALUE  ||
 ' CACHE '||CACHE_SIZE||
 ' ORDER NOCYCLE ;'
 
 from USER_SEQUENCES


to_date('2012-08-03 00:00:00', 'yyyy-mm-dd hh24:mi:ss')


   select * from pla_user order by prev_login_date desc nulls last;


 decode(currLoginDate,null,'2000-01-01')  将null 变成 其他值




-----正则测试
  select * from  Person_Ids where regexp_like(id_value,'^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$');
        
           select * from Person_Ids where regexp_like(id_value,'^[1-9]\d{5}[1-9][9][8][5,6,7,8,9,]((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{2}[0,2,4,6,8]([0-9]|X)$');
           
           
           select * from tab_gbs_user where HEAD_SCULPTURE_PATH is not null or REAL_PICTURE is not null
           
           
           
               select   * from Tab_Gbs_Custom_Person_Ids where custom_id in
               
               (
                select custom_id from Tab_Gbs_Custom_Person_Ids where
             
                regexp_like(id_value,'^[1-9]\d{5}[1-9][9][8][5,6,7,8,9,]((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{2}[0,2,4,6,8]([0-9]|X)$')
             
             ) and id_type_code=7



--查看所有序列


SELECT ' CREATE SEQUENCE '||SEQUENCE_NAME|| ' INCREMENT BY '||
  INCREMENT_BY ||' START WITH '||LAST_NUMBER||' MAXVALUE '||
  MAX_VALUE ||'   CACHE '||CACHE_SIZE||' ORDER NOCYCLE ;'
  FROM user_SEQUENCES;


---修改表
alter table table_name modify column_name default 0;
---增加字段
alter table table_name add   column_name NUMBER(10);
---修改描述
comment on column table_name.column_name is '收藏次数';

 
 update sns_topic set topic_logo=replace(topic_logo,'http://127.0.0.1:80',null)  where topic_logo like 'http:%'

全连接
union all


俩个表关联更新

 UPDATE sns_topic st  SET st.content=(SELECT st2.content FROM sns_topic_20121030 st2  WHERE st.topic_id=st2.topic_id)

系统时间
select sysdate from dual

oracle获取当前服务器时间

to_char(sysdate, 'YYYY/MM/DD   hh24:mi:ss ')

 to_char 是把日期或数字转换为字符串

  to_date 是把字符串转换为数据库中得日期类型

to_date('2008-01-25 12:39:49','yyyy-MM-dd HH24:mi:ss')

  insert into  sys_permission (id,name,code,type,urls)  
        select id,title,name,'MENU',href  from sys_menu where name like '%menu_mobile_mgr%'


CASE WHEN 用法

(CASE
WHEN  LENGTH(rownum) <2 THEN za.area_code||'00'||rownum
WHEN  LENGTH(rownum) <3 THEN za.area_code||'0'||rownum
else za.area_code||rownum end)


oracle 系统管理 linux下

一 装好oracle sqlplus连接不上
   应该是防火墙没关

    CentOS Linux开启和关闭防火墙命令有两种,一种是临时的,重启即复原;另外一种是永久性的,重启不会复原。

    1) 临时生效,重启后复原    
    开启: service iptables start
    关闭: service iptables stop

    2) 永久性生效,重启后不会复原
    开启: chkconfig iptables on
    关闭: chkconfig iptables off



 
二 更改缓冲池
alter system set shared_pool_size=300M。 8G 大概设置 300M
create spfile from pfile;
show parameter sga
show parameter target
shutdown immediate;

三 连接数据库
sqlplus scott/tiger@192.168.2.192/orcl  连接oracle

四 出现无监听/监听器目前不知道连接描述符中请求的服务
    1.停止监听(lsnrctl stop)
    2.停止数据库 进入sqlplus (用 sys as sysdba 登录 ,输入startup(shutdown) 启动数据库(exit))
    3.如果原来有监听,删除原来监听,然后配置新监听(监听IP地址些服务器IP)
    4.启动监听 重新启动监听 先停止(lsnrctl stop )后(lsnrctl start )
    5.启动数据库 进入sqlplus(用 sys as sysdba 登录 ,输入startup(shutdown) 启动数据库(exit))

   
    查看监听情况 (lsnrctl status)
   
 
   
   
五:进入oracle图形化界面配置监听
监听 命令:   netca
打开 net manger 命令: netmgr

 select instance_name,status from v$instance;

shutdown 停止数据库



0 0
原创粉丝点击