lvextend -L +40000m /dev/mapper/VolGroup00-LogVol04

 ext2online /dev/mapper/VolGroup00-LogVol04
 
创建tablespace TS_BSWDB_DATA 用来存日志流水数据 (数据保留3年)
创建tablespace TS_BSWDB_INDEX 用来存日志流水数据索引 (数据保留3年)
 
创建tablespace TS_MGMDB 用来存静态数据(不会增长 1G 空间)
 
create user bswdb identified by bswdb default tablespace TS_BSWDB_DATA temporary tablespace temp;
 
create user mgmdb identified by mgmdb default tablespace TS_MGMDB temporary tablespace temp;
 
 
grant resource,connect to bswdb;
 
grant dba,resource,connect to mgmdb;
 
 
create tablespace TS_BSWDB_DATA datafile
'+DGORA/NBPREDB/DATAFILE/TS_BSWDB_DATA_01.dat' size 10g AUTOEXTEND OFF
EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
 
create tablespace TS_BSWDB_INDEX datafile
'+DGORA/NBPREDB/DATAFILE/TS_BSWDB_INDEX_01.dat' size 5g AUTOEXTEND OFF
EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
 
create tablespace TS_MGMDB datafile
'+DGORA/NBPREDB/DATAFILE/TS_MGMDB_01.dat' size 1g AUTOEXTEND OFF
EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
 
 
查询oracle server端的字符集 
有很多种方法可以查出oracle client端的字符集,比较直观的查询方法是以下这种:
SQL> select userenv('language') from dual;
SIMPLIFIED CHINESE_CHINA.AL32UTF8
 
如何查询dmp文件的字符集 
 
用oracle的exp工具导出的dmp文件也包含了字符集信息,dmp文件的第2和第3个字节记录了dmp文件的字符集。如果dmp文件不大,比如只有几M或几十M,可以用UltraEdit打开(16进制方式),看第2第3个字节的内容,如0354,然后用以下SQL查出它对应的字符集: 
SQL> select nls_charset_name(to_number('0354','xxxx')) from dual; 
 
 
 
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK 
 
select * from dba_tablespaces;
select * from dba_data_files ;
 
 
#正在执行的sql语句
SELECT   osuser,   username,   sql_text   from   v$session   a,   v$sqlarea   b   where   a.sql_address   =b.address   order   by   address;
 
 
 oracle查看锁表进程
oracle查看锁表进程,杀掉锁表进程
2008-10-22 16:01
查看锁表进程SQL语句1: 
  SELECT l.session_id sid,
       s.serial#,
       l.locked_mode ,
       l.oracle_username ,
       l.os_user_name ,
       s.machine ,
       s.terminal ,
       o.object_name ,
       s.logon_time
FROM v$locked_object l, all_objects o, v$session s
WHERE l.object_id = o.object_id
   AND l.session_id = s.sid
ORDER BY sid, s.serial#;
 
查看锁表进程SQL语句2:
select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID;
 
杀掉锁表进程: 
如有記錄則表示有lock,記錄下SID和serial# ,將記錄的ID替換下面的 80,33,即可解除LOCK
alter system kill session '158,306';
 
##查数据文件大小,缩小文件
 
select * from dba_data_files;
 
alter database datafile '/oracle/app/oracle/oradata/orcl/users01.dbf' resize 2G;
 
###更改临时表空间
 
ALTER DATABASE TEMPFILE  '/oracle/app/oracle/oradata/orcl/temp01.dbf' DROP;
 
ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/app/oracle/oradata/orcl/temp01.dbf' SIZE 2G autoextend off;
 
ALTER TABLESPACE TS_NEW_DATA ADD DATAFILE '/app/oracle/oradata/ORCL/TS_NEW_DATA_03.dat' SIZE 10G autoextend off;
 
 
##### 查用户表哪个占得空间大
col tablespace format a20 
select 
  b.tablespace_name  表空间, 
  round(SUM(NVL(b.bytes,0))/1024/1024,2)     总容量M, 
  ROUND((SUM(NVL(b.bytes,0))-sum(nvl(a.bytes,0)))/1024/1024,2)   已使用M, 
  ROUND(sum(nvl(a.bytes,0))/1024/1024,2)        剩余, 
  sum(nvl(a.bytes,0))/Sum(NVL(b.bytes,0))*100 剩余百分比  
  from dba_free_space a,dba_data_files b ,dba_users c
  where a.file_id=b.file_id
--    And   a.tablespace_name = c.DEFAULT_TABLESPACE
--    And c.username = &DD
  group by b.tablespace_name
  order by b.tablespace_name ;
 
1、表占用空间
 
 
select segment_name, sum(bytes)/1024/1024 Mbytese from user_segments where segment_type='TABLE' group by segment_name order by Mbytese desc, segment_name;
 
 
2、索引占用空间
select segment_name ,sum(bytes)/1024/1024 from user_segments where segment_type ='INDEX' group by segment_name;
 
 
3 TEMP 表空间占用
 select y.BYTES_USED/1024/1024/1024 as used_G,y.BYTES_FREE/1024/1024/1024 as free_G , y.* from v$temp_space_header y
 
#临时表空间太大解决办法
 
 
create temporary tablespace TEMP2 TEMPFILE  '/app/oracle/oradata/ORCLYZ/temp02.dbf' size 2M reuse;
alter database default temporary tablespace TEMP2;
drop tablespace temp including contents and datafiles;
create temporary tablespace TEMP TEMPFILE '/app/oracle/oradata/ORCLYZ/temp01.dbf' size 20G reuse autoextend on;
alter database default temporary tablespace temp;
drop tablespace temp2 including contents and datafiles;
alter user switch temporary tablespace temp;
 
###查询表空间大小
SELECT UPPER(F.TABLESPACE_NAME) "表空间名",
       D.TOT_GROOTTE_MB "表空间大小(M)",
       D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",
       TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,
                     2),
               '990.99') "使用比",
       F.TOTAL_BYTES "空闲空间(M)",
       F.MAX_BYTES "最大块(M)"
  FROM (SELECT TABLESPACE_NAME,
               ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,
               ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES
          FROM SYS.DBA_FREE_SPACE
         GROUP BY TABLESPACE_NAME) F,
       (SELECT DD.TABLESPACE_NAME,
               ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB
          FROM SYS.DBA_DATA_FILES DD
         GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDER BY 4 DESC
 
 
########磁盘读写最多的语句
    SELECT * FROM (
   SELECT PARSING_USER_ID
     EXECUTIONS,
     SORTS,
     COMMAND_TYPE,
     DISK_READS,
cpu_time,
     sql_text
   FROM v$sqlarea
   ORDER BY disk_reads DESC ) 
  WHERE ROWNUM<10 ; 
 
 
#清空回收站
PURGE RECYCLEBIN
 
 
analyze talbe