基于OCI 实现的 最高效dump程序, 比OTL 以及其他的接口都快很多
能执行任何sql , 自动识别字段名和字段类型,进行输出输出
/*
* oracle_dump.cpp
*
* Created on: 2010-2-1
* Author: clm971910@gmail.com
*
* 压缩
* 4216351 dump done
* 完整 106 秒
* 写分隔符 8秒
* 压缩写磁盘 34秒
* 读数据 9秒
* 数据库查询 54秒
*/
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <getopt.h>
#include <oci.h>
#include <oratypes.h>
#include <ocidfn.h>
#ifdef __STDC__
#include <ociapr.h>
#else
#include <ocikpr.h>
#endif
#include <ocidem.h>
#include "tbZip.h"
using namespace std;
/* =================== macro =====================*/
#define MAX_SELECT_COL_SIZE 1000 /* ......
在 Windows 上安装 Oracle 数据库 11g
安装Oracle 软件,必须使用 Oracle Universal Installer。
1.在这一安装中,您需要使用 DVD 或下载 DVD 版本。在本教程中,将从已下载的版本进行安装。在解压缩 DVD 文件的目录中,打开 Windows 资源浏览器并双击 \db\Disk1 目录的 setup.exe。
2.安装的产品为 Oracle Database 11g。选定该产品并点击 Next。
3.您将通过一个入门级数据库来执行基本安装。输入 orcl 作为 Global Database Name 以及 oracle 作为 Database Password 并确认口令。然后单击 Next。
4.Oracle Configuration Manager 允许您将配置信息与 Metalink 帐户相关联。您可在该窗口上选择启用它。然后单击 Next。
5.查看 Summary 窗口,验证要安装的内容。然后单击 Install。
6. 进度窗口显示。
7.Configuration Assistants 窗口显示。
8.正在创建数据库。
9.创建了数据库之后,可以解锁您要使用的用户。单击 OK。
10.单击 Exit。单击 Yes 确认退出。
测试安装
要测试安装是否成功完成,请执行以下步骤:
1.打开一个浏览器,输入以下 URL:
https://<主机名>:1158/em
其中 <主机名> 应 ......
--刪除重復列
a.如果有ID字段,就是具有唯一性的字段
delect table where id not in (
select max(id) from table group by col1,col2,col3...
)
group by 子句后跟的字段就是你用到判斷重复的字段
b.,如果是判斷所有字段
select * into #aa from table group by id1,id2,....
delete table table
insert into table
select * from #aa
c.如果表中有ID的情況
select identity(int,1,1) as id,* into #temp   ......
如何手工创建Oracle数据库
http://www.cnhacker.com/Security/System/200808/t20080818_6325.html
今天,我在测试机器上来了个误操作rm * backup/*,把正在运行的数据库中的数据文件全部删除了,真是郁闷!还好这个是给我们新人们测试玩的,要不然就死定了!在此也做一个提醒,身为DBA,要永远记住什么慎用或者禁止使用rm命令,万不得以的情况下,使用时在敲enter也要看了又看、慎重又慎重才行!好了,费话不说了,下面请看我的过程。
Red Hat Enterprise 3 + Oracle 10g Release 2
$su – oracle
1、设置系统环境变量
ORACLE_HOME=/opt/oracle/product/10.2
ORACLE_BASE=/opt/oracle
ORACLE_SID=dbtest
......
2、系统规划
实例名称ORACLE_SID=dbtest
数据库名称DB_NAME=dbtest
3、手工创建如下目录
/opt/oracle/admin/dbtest/cdump
/opt/oracle/admin/dbtest/bdump
/opt/oracle/admin/dbtest/udump
/opt/oracle/admin/dbtest/pfile
/opt/oracle/oradata/dbtest/
/opt/oracle/oradata/dbtest/archive
4、建立密码文件
orapwd file=/opt/oracle/product/10.2/dbs/orapwd_dbtest password=superman
5、修改参数文件
格式:/opt/oracle/product/10.2/db ......
首先查看数据库现有模式可使用以下语句
select name,log_mode from v$database;
也可以用下面的语句
archive log list;(该方法需要as sysdba)
对于非归档模式的数据库该为归档模式(主要以Oracle 10g为参考)使用以下步骤:
1. SQL> alter system set log_archive_dest_1='location=/oracle/oracle10g/log/archive_log';
该语句含义是确定归档日志的路径,实际上Oracle 10g可以生成多份一样的日志,保存多个位置,以防不测
例如再添加一个日志位置可使用以下语句
SQL>alter system set log_archive_dest_2='location=/oracle/oracle10g/log2/archive_log';
查看归档日志的路径
SQL>show parameter db_recovery_file_dest
或者
SQL>archive log list;
2.关闭数据库
SQL> shutdown immediate
3.启动数据mount状态:
SQL> startup mount;
4、修改数据库为归档模式:
SQL> alter database archivelog;
5、打开数据库,查询:
SQL> alter database open;
修改日志文件命名格式:
SQL> alter system set log_archive_max_processes = 5;
SQL> alter system set log_archive_format = "archive_%t_%s_%r.log" scope=spfile;
......
我们可以通过下面的语句来查询数据库的默认临时表空间:
SQL> select * from database_properties where property_name = 'DEFAULT_TEMP_TABLESPACE';
默认临时表空间的限制:
1. 默认临时表空间必须是TEMPORARY的:
SQL> alter database default temporary tablespace tools;
alter database default temporary tablespace tools
*
ERROR at line 1:
ORA-12902: default temporary tablespace must be SYSTEM or of TEMPORARY type
2. 默认临时表空间一旦被指定,将无法在改成PERMANET:
SQL> alter tablespace temp2 permanent;
alter tablespace temp2 permanent
*
ERROR at line 1:
ORA-12904: default temporary tablespace cannot be altered to PERMANENT type
3. 在删除默认临时表空间必须先重新指定默认临时表空间:
SQL> drop tablespace temp including contents and datafiles;
drop tablespace temp including contents and ......