Oracle笔记
occi笔记整理

一.Oracle oci工具包安装:$ORACLE_HOME\BIN:执行文件和help文件$ORACLE_HOME\OCI\INCLUDE:头文件$ORACLE_HOME\OCI\LIB\BC: for Borlanf C++的OCI库$ORACLE_HOME\OCI\LIB\MSVC: for MS Visual C++的OCI库如果是unix下,对于ORACLE8i,则OCI库在$ORACLE_HOME/lib下,如果是9i,则在$ORACLE_HOME/lib32下,库文件名一般为libclntsh.so1.创建OCI环境即创建和初始化OCI工作环境,其他的OCI函数需要OCI环境才能执行。
2.需要申请的句柄类型:OCI环境句柄: OCI_HTYPE_ENV—它定义所有OCI函数的环境调用环境,是其他句柄的父句柄。
(由OCIEnvInit或OCIEnvCreate生成)错误句柄:OCI_HTYPE_ERROR—作为一些OCI函数的参数,用来记录这些OCI函数操作过程中所产生的错误,当有错误发生时,可用COIErrorGet()来读取错误句柄中记录的错误信息。
服务器环境句柄:OCI_HTYPE_SVCCTX—定义OCI调用的服务器操作环境,它包含服务器、用户会话和事务三种句柄。
服务器句柄:OCI_HTYPE_SERVER—标识数据源,它转换为与服务器的物理连接。
用户会话句柄:OCI_HTYPE_SESSION—定义用户角色和权限及OCI调用的执行环境。
事务句柄:OCI_HTYPE_TRANS—定义执行SQL操作的事务环境,事务环境中包含用户的会话状态信息。
语句句柄:OCI_HTYPE_STMT—是一个标识SQL语句或PL/SQL块,以及其相关属性的环境。
Bind/Define句柄:属于语句句柄的子句柄,由OCI库隐式自动生成。
用户不需要自己再申请,OCI输入变量存储在bind 句柄中,输出变量存储在定义句柄中3.句柄属性包括:服务器环境句柄属性:(OCI_HTYPE_SVCCTX)OCI_ATTR_SERVER—设置/读取服务环境的服务器环境属性OCI_ATTR_SESSION—设置/读取服务环境的会话认证环境属性OCI_ATTR_TRANS—设置/读取服务环境的事务环境属性用户会话句柄属性:(OCI_HTYPE_SESSION)OCI_ATTR_USERNAME—设置会话认证所使用的用户名OCI_ATTR_PASSWORD—设置会话认证所使用的用户口令服务器句柄:(OCI_HTYPE_SEVER)OCI_ATTR_NOBLOCKING_MODE—设置/读取服务器连接:=TRUE时服务器连接设置为非阻塞方式语句句柄:(OCI_HTYPE_STMT)OCI_ATTR_ROW_COUNT—只读,为当前已处理的行数,其default=1OCI_ATTR_STMT_TYPE—读取当前SQL语句的类型:Eg : OCI_STMT_BEGINOCI_STMT_SELECT OCI_STMT_INSERTOCI_STMT_UPDATE OCI_STMT_DELETEOCI_ATTR_PARAM_COUNT—返回语句选择列表中的列数4.关于输出变量定义:如果在语句执行前就知道select语句的选择列表结构,则定义输出操作可在调用 OCISTMTExecute前进行,如果查询语句的参数为用户动态输入的,则必须在执行后定义。
oracle rac 安装部署文档

oracle rac 安装部署文档oracle oracle rac搭建][常见问题汇总oracle rac 安装部署文档物理硬件配置需求:oracle 虚拟机需求:oracle rac两节点脚本搭建方法操作系统安装数据库安装oracle rac 图形界面搭建方法(适用于两个节点和多个oracle节点)创建磁盘组安装oracle数据库dbca 创建数据库配置oracle性能测试相关的参数关闭iolog常见问题汇总问题一:oracle在运行过程中,异常中断存储进程(gluster,tgtd等)会导致oracle异常报错ORA-01078。
问题二:查看数据库实例状态的时候报错ORA-01034问题三:删除问题表失败问题四:通过系统镜像安装桌面。
问题五:执行完oracle_install_rac.sh 如果oracleasm 命令未别找到,要先解压rpm文件夹问题六:rac01 和rac02 sid配置成一样的了怎么修改问题七:请求spfile错误问题八:ora 12516报错监听程序找不到符合协议堆栈要求的可用处理程序问题九:问题启动数据库报错 ORA-01078物理硬件配置需求:oracle 虚拟机需求:oracle rac两节点脚本搭建方法操作系统安装1.页面选择部署oracle rac2.选择共享盘创建,单机下一步3.配置虚拟机基本信息,– cpu改成2*16核,– 内存改成96G,– 添加一个网卡,连接心跳交换机– 磁盘添加iso redhat镜像文件– 磁盘设置为80G 预先分配网络配置第一个网口作为虚拟机的公网,第二个网口作为虚拟机的私网网口(连接heartbeat交换机的网口)4.单击下一步,安装redhat操作系统 [以下简略提示4点]1.hostname可以先不改2.创建分区的时候,选择Create Custom Layout自己配置分区大小3.创建分区/boot 分区1024M,swap 分区20480M,剩余的空间分配给/分区4.安装的时候选择带桌面的5.red hat系统安装完成后,按页面提示,安装虚拟机性能优化工具(不安装性能优化工具,会导致测试性能的时候,性能大幅下降)6.安装完成后,将虚拟机关机。
thin-horse RMAN笔记

一开始使用Recovery ManagerRMAN的功能如果备份了数据文件以及从最近一次备份开始生成的所有归档日志的副本,那么在发生任何灾难的情况下都能够完成不丢失数据的恢复操作。
此时不能恢复的唯一例外是丢失了当前联机重做日志文件的所有副本。
RMAN能够备份的对象是整个数据库多单独的表空间与数据文件。
RMAN还能够备份控制文件,服务器参数文件以及归档日志。
数据库中不能被备份的唯一部分是联机重做日志文件:这些文件通过复用受到保护。
这些备份可以是映像副本或备份集。
备份集是一种能够直接流入磁带并可选择压缩的专用格式。
RMAN能够进行增量备份,增量备份可以显著地减少备份数据量。
RMAN甚至可以将增量备份应用于全部备份,这样会使备份时间更近,从而能够减少所需的恢复时间。
与完整备份的时间相比较,增量备份的时间也将大大减少。
使用传统的方法时,还原与恢复操作的粒度为数据文件,RMAN还原与恢复的粒度可以只是一个讹误的数据文件块,从而能够显著地减少MTTR。
实际上,通过使用块级介质恢复,我们可以在不停机的情况下检测与修复受损的文件。
RMAN在扫描数据块时会验证其内容,这意味着DBA能够先于终端用户发现问题。
为了利用RMAN的所有功能,就需要集成一个磁带库,随后,整个备份与恢复操作可以被完全委派给RMAN。
RMAN能够控制这个磁带库并根据需要载入,读取,写入和清空磁带。
将RMAN与磁带库结合在一起意味着备份例程可以无限期地自动运行,同时能够完全确保恢复任何灾难。
RMAN的组件在Linux中,用于管理RMAN的交互式工具为rman。
这个工具位于ORACLE_HOME/bin目录内,并且提供了一个到RMAN得命令行接口。
它是一个与其他用户进程相似的进程,这个进程通过一个侦听器与一个服务器进程连接数据库,提示用户输入命令,并且将命令发送至实例执行。
Database Control是另一种可以使用RMAN的用户接口工具。
不管使用那一种接口,实际上都会调用PL/SQL 过程。
jfinal学习笔记

jfinal框架教程-学习笔记上一节介绍了jfinal框架的简单搭建,这节通过一个小例子了解jfinal 的结构和特点先上图1、建数据库(我用的是oracle数据库,其他的相对也差不多)-- Create tablecreate table CLASSES(classesid NUMBER not null,classesname VARCHAR2(20),classesaddress VARCHAR2(50));-- Create tablecreate table STUDENT(studentid NUMBER not null,studentname VARCHAR2(10),studentage NUMBER,studentsex VARCHAR2(2),classesid NUMBER);alter table STUDENTadd constraint FK_CLASSESID foreign key (CLASSESID) references CLASSES (CLASSESID);新建项目,我用的myeclipse,先把jar包导入2、实体类Classes.javapackage com.demo.model;import com.jfinal.plugin.activerecord.Model;public class Classes extends Model<Classes//表名> { public static final Classes dao = new Classes(); }Student.javapackage com.demo.model;import com.jfinal.plugin.activerecord.Model;public class Student extends Model< Student//表名> { public static final Student dao = new Student();public Classes getClasses() {return Classes.dao.findById(get("classesid"));//表的属性}}什么这是实体类?没错!!~ ActiveRecord 是jfinal 最核心的组成部分之一,通过ActiveRecord 来操作数据库,将极大地减少代码量,极大地提升开发效率,配置在后面,我这里用的是Model,Model 是ActiveRecord 中最重要的组件之一,它充当MVC 模式中的Model部分。
logminer学习笔记

据库的改变有关的历史信息,包含,但不局限t、Update、Delete或者是DDL)名句的用户信息了回滚UNDO该变化所需的SQL语句。
特性接/迁移行、CLUSTER表操作、DIRECT PATH NR_CONTENTS的SQL_REDO中可以看到除外,其中的密码将以加密的形式出现,而NG初始化参数设为TRUE,则所有操作的数基于实际涉及到的数据的查询。
例如涉及一个员工工资由1000变成2000的原始更新语句,语句。
化标识符来标识表和其相关的列,为了重建标识符和用户定义的名称之间的映射关系。
(Dictionary)中。
LogMiner提供了一个程序提取该数据字典。
和几个视图:一个用于提取数据字典信息的过程,即包含一个重建LogMiner表的过程,认情况下,LogMiner的表是建在SYSTEM表过程:解LogMiner怎样利用redo log和字典文件是的结果并规划对系统资源的利用。
现在将讨论所需要分析的redo log的名称,LogMiner检过V$LOGMNR_CONTENTS视图返回结果。
需的信息,你必须打开至少最小的追加日志询V$LOGMNR_CONTETNS视图。
每一次对询都会使redo log文件被依次读取。
要点:来自8.0或之后的版本。
然而,某些LogMiner内容,LogMiner需要访问一个数据库字典。
内部的对象标识符和数据类型转换为对象名Miner将使用16进制字符显示内部对象ID。
INSERT INTO emp(name, salary) VALUES ('John Doe', 50000);LogMiner将显示为:insert into Object#2581(col#1, col#2)values (hextoraw('4a6f686e20446f65'),hextoraw('c306'));"字典文件必须具有和产生redo日志的数据库相同的字符集。
数据库——甲骨文学习笔记

目录 ................................................................................................................ 错误!未定义书签。
一、创建表 (2)创建表一 (2)创建表二 (2)创建表三 (3)二、添加、修改、删除 (3)添加 (3)修改 (4)删除 (4)三、ORACLE 10g新增的数据类型 (4)说明 (4)示例 (5)特殊值 (5)四、ORACLE PL/SQL简介 (5)1 块结构 (5)2 变量和类型 (6)3 条件逻辑 (6)4 循环 (7)5 游标 (8)№1声明一些变量,用于保存select语句的返回的列值 (8)№2声明游标,并指定select语句 (9)№3打开游标 (9)№4从游标中获取记录 (9)№5关闭游标 (10)№6完整的示例 (10)№7游标与for循环 (10)6 异常 (12)7 存储过程 (12)№1创建过程 (12)№2调用过程 (13)№3获取过程信息 (13)№4删除过程 (13)№5查看过程中的错误 (14)№6实际应用示例(积分清零) (14)8 函数 (15)№1创建函数 (15)№2调用函数 (16)№3获取函数信息 (16)№4删除函数 (17)№5实际应用示例(查找表) (17)9 包 (20)№1创建包和规范 (20)№2创建包体 (21)№3调用包中的过程和函数 (22)№4获取有关包中的函数和过程的信息 (22)№5删除包 (22)10触发器 (22)№1触发器运行的时机 (22)№2设置示例触发器的准备工作 (23)№3创建触发器 (23)№4激活触发器 (24)№5获取有关触发器的信息 (24)№6禁用和启用触发器 (25)№7删除触发器 (25)№8实际应用示例(增加修改积分) (25)一、创建表创建表一CREATE TABLE TABLE_NAME (AAA INTEGERCONSTRAINT约束名PRIMARY KEY,BBB V ARCHAR2(10) NOT NULL,DOB DATE,CCC V ARCHAR2(14),);说明:CONSTRAINT子句用来限制存储在表或列中的值。
ODI学习笔记
Oracle Data IntegratorHands-onStudents HandbookAuthorsNicolasFXDupupetChristopheContributors/ReviewersMalfroyNickJulienTestutDahlmanMatthewOracle CorporationWorld Headquarters500 Oracle ParkwayRedwood Shores, CA 94065USAWorldwide inquiries:Phone: +1 650 506 7000Fax: +1 650 506 7200Oracle is the information companyOracle is a registered trademark of Oracle Corporation.Various product and service names referenced herein may be trademarks of Oracle Corporation. All other product and service names mentioned may be trademarks of their respective owners.Copyright © 2007 Oracle CorporationAll rights reserved.Exercises for Lesson 3Designer Simple Transformations1. IntroductionWe will first start with what ODI developers do most: design data transformations and data flows. In our first set of exercises, we will use an environment where all administration tasks have been done for us: connectivity to the databases, import of the metadata are done for us, so that we can focus immediately on what make “a day in the life of an ODI developer”. Later in this training, we will get back to the definition of the connectivity and the import of the metadata.The Hands on Virtual machine contains an ODI repository organized in projects that match the lessons of this course. The exercises for lesson 3 will use the project called “Lesson 3 – One Source“. The solution for these exercises is available in the project called “Lesson 3 – One Source - Solved“. The same logic will apply for all other lessons.2. First ProjectIn the Project tab of Designer, we will now work on our first project: Lesson 3 – One SourceFor this first project, the appropriate Knowledge Modules (KMs) have already been loaded. You can see them under the Knowledge Module folder, under the Loading and Integration entries. In later projects, our first task will be to import the KMs that you will then use for your transformations. For the current project, this has been done for us.It is usually recommended to load only the necessary KMs for a given project, as it will increase your productivity.For this first set of exercises, we have the following KMs:LKM SQL to OracleIKM SQL Control Append3. Create Your First InterfaceExpand the project Lesson 3 – One Source. Expand the folder First Folder, right-click on Interfaces and select Insert Interfaces.Name of the interface: Customer Lesson3Then click on the Diagram tab, and drag and drop the source and target tables in the interface.To do this, select the Model tab in the tree on the left,and expand the models where the tables are defined:Source table: CUSTOMER from SQL Server SalesTarget table: CUSTOMER from Oracle Sales WarehouseWhen ODI asks if you want to perform an automatic mapping, select Yes to automatically map all the columns that have the same name in both models.3.1 MappingsWe want the following mappings:SQL server column OracleColumnTransformation SQLSyntaxDear Dear Change 0 into MrChange 1 into MrsChange 2 into Ms Casewhen<expression> then <value>when<expression> then <value>else<value>EndFirst_Name, Last_Name CUST_NAME Concatenate the firstname and the lastname. Capitalize thefirst letter for both.Put a space betweenfirst and last nameUse a + sign on SQLserver, or a || on Oracle.Use InitCap on Oracle toinitialize the first letter.Address Address NonePhone Phone NoneAge Age NoneAge_RangeNotmappedSales_PersNotMappedCre-Date System date on thetarget machine. Donot modify this valueif there is an updateSysdate on OracleUpd_Date System date on thetarget machineSysdate on Oracle Custid Cust_id NoneCity_id City_id NoneTo perform a mapping:- click on the target column- this will open the mapping area at the bottom of your screen- drag and drop the columns you need for your transformations in that mapping area (not on the target column, how tempting it may be). You can build your transformation logic in this field.- if you scroll down a little bit in the mapping area, you can choose on which system the mapping will be executed (source, staging area, target). Except for literals, mappings are always on the source or the staging area. The staging area is on the target system by default.- write the mapping expression using the appropriate SQL for the database you have chosen. You can use the expression editor to get some help with the appropriate syntax.3.2 FiltersCreate a filter to load only customer with a CUSTID less than 105. To create a filter, drag and drop the column CUSTID from SQL server in the dark gray area on the source side. This creates a yellow funnel (the icon for a filter). In the mapping area at the bottom, enter:CUSTOMER.CUSTID<1053.3 Data FlowCheck in the Flow tab that the Knowledge Modules are properly loaded. They should have been selected by default. Click on the caption representing the source and target systems to view the selected KMs.Leave the default options in the LKM.Change options as follows for the IKM:<Default>:YesInsertCommit <Default>:YesFlow Control NoRecycle Errors <Default>:NoControl <Default>:NoStaticTruncate <Default>:NoYesAllDeleteCreate Target Table <Default>:NoDelete Temporary Objects <Default>:Yes4. RunClick the Execute button, at the bottom right. Then click Ok on the following window.Then go in the operator interface , and expand All Executions to see the outcome of your job. If you have an error (red stop sign) go back to your interface and fix the problem.Understanding the logs:- The first level identifies your session. (in the above screen shot: 43020 – Customer Lesson3 – 2007-05-30)- The second level identifies the step that was executed. In our case, we are executing a single step job: an interface. Later on, we will see objects that can execute and sequence multiple steps: the packages. The step for our interface in the above screenshot is 1-Customer Lesson3 – 2007-05-30- Each step is made of multiple tasks, which are generated by the Knowledge Modules that we have selected in the interface.At each level, you can double-click on the colored bullets (green, red, yellow, blue) at the beginning of the line to get more details on the execution of the job: - The Definition tab will have general information (agent, context used for the execution)- The Execution tab will have statistical information (duration, number of rows processed, number of inserts, deletes, updates, errors). This is also where you will see error messages reported by the databases.- The Description tab will contain the generated code that was executed by the database.In our case, a correct execution should insert 5 records in the target table. To check out how many records where loaded, double- click on the entry 1 – Customer Lesson3 in the operator interface, and select the Execution tab in the window that will open. Statistics are available in this screen:Exercises for Lesson 4DesignerTransformations1. IntroductionNow that we have successfully created a first basic interface, build a more complex one, by introducing heterogeneous components.2. Open the InterfaceThe project Lesson 04 – Heterogeneous contains a basic interface (the same as the one we built in the previous lesson).To open this interface, you can:- Either double-click on the interface name in the tree- Or right-click and select Edit.In the definition tab, rename the interface to: Customer Lesson 4-13. Modify the InterfaceModify the interface as follows:Source tables:- Add the CITY table from SQL Server SalesJoin the two source tables on CITY_ID:- Drag and drop the CITY_ID column from CUSTOMER table on the column CITY_ID from CITY. This will automatically create the joinexpression.3.1 MappingsChange the mapping for CITY_ID. Replace the mapping so that we now retrieve the CITY_ID from the CITY tableSQL server column Oracle Column TransformationCity_id from CITY City_id None3.3 Data FlowClick on the Flow tab of the interface.Notice that there is very little change here. Both source tables are on the same server, as such they will be joined before any extraction can be done. There is no need for any additional KM..Change options as follows for the IKM (click on the caption of the box that represents the target system):<Default>:YesInsertCommit <Default>:YesFlow Control NoRecycle Errors <Default>:NoStaticControl <Default>:NoTruncate <Default>:NoYesDeleteAllCreate Target Table <Default>:NoDelete Temporary Objects <Default>:Yes4. RunClick the Execute button. Then go in the operator interface, and expand All Executions to see the outcome of your job. If you have an error (red stop sign) go back to your interface and fix the problem.A successful run should have inserted 5 records.5. Heterogeneous sourcesWe will now modify this same interface further and add two additional sources. First close the interface, then right-click on the interface name and select duplicate. This will create a copy of your interface. Open this new interface and rename it Customer Lesson 4-25.1 SourcesModify the interface as follows:Source tables:- Add SRC_AGE_GROUP.TXT and SRC_SALES_PERSON.TXT, from the Flat Files Sources model.5.2 JoinsJoin CUSTOMERS with SRC_SALES_PERSON.txt on SALES_PERS_ID and SALES_IDJoin CUSTOMERS with SRC_AGE_GROUP.txt with the AGE between theAGE_MIN and the AGE_MAX5.3 MappingsAuto-mapping should have filled in the columns that were not mapped so far. The mappings should now be:SQL server column Oracle Column TransformationDear Dear Change 0 into MrChange 1 into MrsChange 2 into MsFirst_Name, Last_Name CUST_NAME Concatenate the firstname and the last name.Capitalize the first letterfor both. Put a spacebetween first and lastnameAddress Address None Phone Phone None Age Age NoneAge_Range Age_Range from FileConcatenate Sales repsSales_Persfirst name and last name.Do an RTRIM on both theFirst name and the lastnameCre-Date System date on thetarget machine. Do notmodify this value if thereis an updateUpd_Date System date on thetarget machineCustid Cust_id None City_id City_id None5.4 Data FlowWe now have more source systems, and these different source systems arevisible in the Flow tab. Notice that for the new systems (our two flat files), we now have a choice of LKMs. Make sure that both files use LKM File to SQL to loaddata into Oracle.5.5 RunClick the Execute button. Then go in the operator interface, and expand All Executions to see the outcome of your job. If you have an error (red stop sign) go back to your interface and fix the problem.A successful interface should insert 5 records.Exercises for Lesson 5 Transformations, Introduction to Metadata and XML Sources1. IntroductionIn this set of exercises, we will add an XML file to our sources. For this, we willfirst reverse-engineer an XML file to introduce the notion of Metadata. Then wewill use the imported Metadata to replace one of the flat files we were using inthe previous lesson.2. Reverse engineer the XML fileThe path to the XML file (as well as the name of the file) are defined in the Topology interface. The most advanced students can investigate the Topologyand look at the definition of the XML data server, but we will cover this in the next chapter. For the time being, we will use the pre-defined schemas from the Topology interface.In Designer, select the Model tab in the tree view.To create a new model click on the icon circled below:The following window will be displayed:Set the values as follows:- Name: XML_SALES_REPS_5- Code: XML_SALES_REPS_5- Technology: XML- Logical Schema: XML_SALESIn the Reverse tab, set the Context to Development:In the Selective Reverse tab, you should see all the elements of the XML file listed as tables if you select the options Selective Reverse, New Datastores and Objects to Reverse. Click the Reverse button to import the metadata.Once you have imported the metadata, check out the following:- List of tables created by ODI during the Reverse Engineering process - Additional columns created by ODI for the conversion of the hierarchical structure into a relational structure (PK columns, FK columns, “order”columns.)3. Use XML as a sourceDouble click on the interface Customer Lesson5Add the following sources:- CITY from MS SQL server- AGE_GROUP from the files file AGE_GROUP.TXT- SALES_PERSON from the XML file- INFO from the XML fileTarget table: CUSTOMERS from Oracle3.1 JoinsJoin CUSTOMERS with AGE_GROUP with the AGE between the AGE_MIN and the AGE_MAXJoin CUSTOMERS with SALES_PERSON on SALES_PERS_ID / SALES_ID Join SALES_PERSON with INFO on SALES_PERSONPK/SALES_PERSONFK.3.2 MappingsAuto-mapping should have filled in the columns that were not mapped so far. The mappings should now be:SQL server column Oracle Column TransformationDear Dear Change 0 into MrChange 1 into MrsChange 2 into MsFirst_Name, Last_Name CUST_NAME Concatenate the firstname and the last name.Capitalize the first letterfor both. Put a spacebetween first and lastnameAddress Address None Phone Phone None Age Age NoneAge_Range from FileAge_RangeSales_Pers Concatenate Sales repsfirst name and last nameCre-Date System date on thetarget machine. Do notmodify this value if thereis an updateUpd_Date System date on thetarget machineCustid Cust_id None City_id City_id None3.3 Data FlowThe XML source is considered as a SQL source: as such, it can use the LKMSQL to Oracle Knowledge Module.Make sure that the flat file uses LKM File to SQL.For the IKM, set the options to the following values:Flow_Control: NODelete_All: YESAll other options must be set to their default value.3.4 RunClick the Execute button. Then go in the operator interface, and expand All Executions to see the outcome of your job. If you have an error (red stop sign) go back to your interface and fix the problem.Exercises for Lesson 6 Data Integrity1. IntroductionAs seen in the theoretical part, data quality can be applied on existing resource, as well as applied while transferring data from one system to another. We will cover both aspects of data quality here.2. Update the Project: Import the Knowledge ModulesSo far, all the projects we have used already had the necessary KM. In real life, you have to import the KMs for your projects. Here, we will import KMs that we will need for data quality:• CKM Oracle•IKM Oracle Incremental UpdateTo import the KMs, right click on the project name (Lesson 6 – Data Integrity) and select Import / Import Knowledge Modules. The KMs are in the following directory:- ../impexp- or C:\Program Files\oracle\oracledi\oracledi\impexpYou can select multiple KMs together when you do the import.3. Check the Quality of Existing Data In the Model SQL_Server_Sales that contains the tables from Microsoft SQL server, expand the CUSTOMER table and add the following constraint:- New foreign key (reference): CITY_ID must match the CITY_ID from the CITY tableHint: Expand the table name. Right click on constraints and select Insert Reference. Select the CITY table from the list. In the Columns tab, add CITY_ID for both tables to define the relationship.Once the foreign key has been defined, go in the Control tab, and click Check to check if existing data in the table would violate the new rule.We expect 8 errors for this control.4. Define Rules to Be Enforced During the Data LoadWe will now define constraints on our target table. On the CUSTOMERS table in Oracle Sales Warehouse, define the following check constraint (or Condition): Name: Age CheckType: Oracle Data Integrator ConditionConstraint: Age>21Error message: Customer age must be over 21Since we already have data in the target table, we can click on the Control tab and check for records that would already violate this constraint.5. Re create the Initial Interface with Data Quality in PlaceThe interface in the project Lesson 6 – Data Integrity is a copy of the one you created in Lesson 4.2. Delete the following elements:- the filter on the Customers table- the City table that is joined with the customersWe are now left with the following source tables:- CUSTOMER from MS SQL server- SRC_AGE_GROUP.TXT and SRC_SALES_PERSON.TXTOur target table is: CUSTOMERS from OracleOur joins are:- CUSTOMERS with SALES_REPS on SALES_PERS_ID- CUSTOMERS with AGE_GROUP with the AGE between the AGE_MIN and the AGE_MAXMappings:- Change the mapping for the customers’ age so that we can experience both inserts and updates;- Use the CITY_ID from the SQL Server CUSTOMER table.Source Column Oracle Column TransformationDear (SQL server) Dear Change 0 into MrChange 1 into MrsChange 2 into MsFirst_Name, Last_Name (SQL server) CUST_NAME Concatenate the firstname and the last name.Capitalize the first letterfor both. Put a spacebetween first and lastnameAddress (SQL server) Address NonePhone (SQL server) Phone NoneAge (SQL server) Age Age+1 Flat File Age_Range Age_Range from FileFlat file Sales_Pers Concatenate Sales repsfirst name and last name(with RTRIM)- Cre-Date System date on thetarget machine. Do notmodify this value if thereis an update- Upd_Date System date on thetarget machineCustid (SQL server) Cust_id NoneCity_id (SQL server) City_id NoneKnowledge Modules;In the Flow tab:On the Staging Area + Target, select the following KM:- IKM Oracle Incremental updateReset all options in the IKM to their default values (click on the caption of theStaging Area + Target box in the Flow tab)In the Control tab:- Select the CKM Oracle.Run the transformation and check the following:- Statistics in the logs: How many errors? How many updates? How many inserts?- On the target table, in the metadata: what are the errors? Why? Hint: you should have 15 errors identified by ODI. If you have 16 errors, make sure that you have updated the mappings for the customer age as described above.There should also be 5 updates and 34 inserts for that process.Bonus question: What can we do with the errors?Exercises for Lesson 7Metadata1. ReviewThe connection to the physical databases and systems has been defined in Topology. From the designer environment, we only need to consider the logical schemas.2. OverviewIn this lesson we will create models. ODI Models contain the metadata needed to build our transformations.3. Assignment1. Oracle:Insert a model for the Oracle metadata:o Name: Oracle Sales DWHo Code: ORACLE_SALES_DWHo Technology: Oracleo Logical Schema: ORACLE_SALES_DWo Context: Development (select this in the “Reverse” tab)In the “Selective Reverse” tab, select all the tables except for the BIN$% tables. Then click on the “Reverse” button at the bottom right of the window to import the metadata for the selected tables.2. Microsoft SQL server:Insert a model for the Microsoft SQL Server metadatao Name: SQL Server Sales DBo Code: MSSQL_CUSTo Technology: Microsoft SQL Servero Logical Schema: MSSQL_CUSTo Context: Development (select this in the “Reverse” tab)3. Flat Files3.1. Insert a model for the File metadatao Name: File Source Datao Code: FILE_DEMO_SRCo Technology: Fileo Logical Schema: FILE_DEMO_SRCo Context: Development (select this in the “Reverse” tab)3.2. Open this file in notepad:C:\Program Files\Oracle\oracledi\oracledi\demo\file\SRC_AGE_GROUP.txtAnswer the following questions about this file's structure:o Fixed or Delimited:o Number of header rows:o RecordSeparator:Separator:o Field3.3. Open this file in notepad:C:\Program Files\Oracle\oracledi\oracledi\demo\file\SRC_SALES_PERSON.txt Answer the following questions about this file's structure:o Fixed or Delimited:o Number of header rows:Separator:o RecordSeparator:o Field3.4. Delimited File:3.4.1. Insert a new Data Store in the model File Source DataSRC_AGE_GROUP.txto Name:o Resource Name: SRC_AGE_GROUP.txt3.4.2. Set the appropriate file format information on the Files tab.Refer to your answers from step 3.2. At this point, you need to clickon “Apply” to save your changes. You will be prompted to lock theobject. Do not lock the object. This would prevent the next step fromworking.3.4.3. On the Reverse Tab reverse the column metadata (click on the“Reverse” button).3.4.4. Apply to save the new file definition. You can manually edit thecolumn names, data types and sizes for each column.3.5. Fixed Format File:3.5.1. Insert a new Data Store in the model File Source Data.SRC_SALES_PERSON.txt o Name:o Resource Name: SRC_SALES_PERSON.txt3.5.2. Set the appropriate file format information on the Files tab.Refer to your answers from step 3.3. At this point, you need to click on “Apply” to save your changes. You will be prompted to lock theobject. Do not lock the object. This would prevent the next step from working.3.5.3. Click the “Reverse” button on the Columns tab and use the"Column Setup Wizard" to define the columns in this fixed width file3.5.4. Apply to save the new file definition. You can manually edit thecolumn names, data types and sizes for each column.3.6. Verify that both file Data Stores is working correctly. Right-click on theData Store and choose to view data. If data is not showing or notproperly aligned, you have to fix the file definition:•Check out the data types: numeric columns will only show numbers •Check out the column sizes•Check out the delimiter if you are using one•If you are using a DATE format, you MUST specify the specific format for the date. Use the following format in the “Format” column:dd/MM/yyyy hh:mm:ssExercises for Lesson 8Topology1. IntroductionSo far, we have used a development environment that had been entirely defined ahead of time for us. We will now define a new environment: the production environment.The environment you have been given in VM Ware contains the following elements:- SQL Server 2005 Express Edition- Oracle Express- Apache Tomcat application server- Flat file sources- XML files sourcesOS login:Username: OraclePassword: oracleAdministrator Login and passwords:MS SQL Server:Username: saPassword: saPort: 1084Oracle:Username: systemPassword:systemOracle Data Integrator has been installed for you. The configuration is as follows: ODI is installed in the following directory:The Master Repository is installed in the following schema on Oracle:REP_TRAININGMSchema/User:REP_TRAININGMPassword:The Work Schema is installed in the following schema on Oracle:REP_TRAININGWSchema/User:REP_TRAININGWPassword:Data tables (source and target) have been createdMS SQL Server:Database: SALES_DEV / SALES_PRODOwner: dboUser:sasaPassword:Oracle:Schema/User: CUST_DW_DEV / CUST_DW_PRODCUST_DW_PROD/CUST_DW_DEVPassword:On each Oracle, a staging schema has been created for your convenience:Schema/User: ODI_TMPODI_TMPPassword:The objective of our hands on sessions will be to move data into our Oracle target database from different types of technologies.2. Definition of contextsThe production context already exists. To see how to create a context, we will simply add a new one: the Testing context.Add a new context called TestingTo add a context, select the context tab. Click the “insert context” icon from the toolbar, and name the context Testing. Do not use a password for this context.Only "Development" and "Production" will be are used in this training. Optionally, other contexts may be added.3. Define connections to SQL Server The connectivity to MS SQL Server has not been defined for you. You will have to go through the following steps to be able to connect:1. Check that the the JDBC driver for MS SQL server has been installed inthe ODI /bin directory (on your machine: c:\programfiles\oracle\oracledi\oracledi\drivers). If not, you will find a copy of thedriver here:C:\Documents andSettings\Oracle.XP_ONE\Desktop\Tools\Microsoft SQLServer 2005 JDBC Driver\sqljdbc_1.1\enu\sqljdbc.jarRemember to stop all ODI components and to restart them each time you copy a new driver.2. In Topology, create a new Data Server under the technology MicrosoftSQL Server. This is done in the Physical Architecture panel.o Name: MS_SQL_XPONE_PRODo User: sao Password: sao JDBC Driver: com.microsoft.sqlserver.jdbc.SQLServerDriverBeware: there are 2 different JDBC drivers for Microsoft SQL server2000 and 2005. Make sure that you select the one for 2005. Thedriver names are very similar, but if you choose the wrong driverthe connection will not work.o JDBC URL:jdbc:sqlserver://xpone:10843. Create a new Physical Schema under the new Data Server.o Database:SALES_PRODo Owner: dboo Database (Work Catalog): SALES_PRODo Owner: dbo4. Link the Physical Schema to the logical schema called MSSQL_CUST.Note: If the schema did not exist, you would have to create it:Either: Insert a new line on the Physical Schema context tab byclicking on the blue grid icon: Select the context, and either select thelogical schema from the drop down menu, or type its name.Or: Insert a new Logical Schema in the Logical Architecture panel.Then map this new schema from either the definition of the logical schema or from the definition of the physical schema.Or:Either:5. You can review the mappings between physical and logical names fromthe definition of the logical schema. Make sure that your logical schemaMSSQL_CUST is correctly linked to physical schemas is each context: o Linked to SALES_DEV in the Development contexto Linked to SALES_PROD in the Production context4. Define connections to OracleFor Oracle, create a second physical schema under the existing server: o Schema: CUST_DW_PRODo Work schema: ODI_TMPo Link the schema to the logical schema ORACLE_XPONE_DW using the Production context5. Define connections for Files & XML For the Files and XML technologies, the physical servers are already defined. The Logical Schemas used are FILE_DEMO_SRC and XML_DEMO_GEO.Use the same Physical Schema in both Development and Production.Note: this is not a technology requirement. We only do this to simplify the environment. Normally the development data and production data are defined as different physical schemas.。
tarena达内数据库五天笔记
·达内Oracle的五天笔记1.1. SQLPLUS的命令初始化表的位置:set NLS_LANG=american_7ascii (设置编码才可以使用下面脚本) cd $ORACLE_HOME/rdbms cd demo summit2.sql*********************************我们目前使用的是oralce 9i 9201 版本select * from v$version;恢复练习表命令:sqlplus **/** @summit2.sql //shell要在这个文件的位置。
登陆oracle的命令:sqlplus 用户名/密码show user 显示当前登陆的身份.set pause onset pause off 分页显示.oracle中默认日期和字符是左对齐,数字是右对齐table or view does not exist ; 表或示图不存在edit 命令用于自动打开vi修改刚修执行过的sql的命令。
修改方法二:l 3 先定位到行 c /旧串/新串执行出错时,利用错误号来查错误:!oerr ora 942 (装完系统后会装一个oerr工具,用于通过错误号来查看错误的具体信息)想在sql中执行unix命令时,把所有的命令前加一个!就可以,或者host( 用于sql从切换至unix环境中去)/*** 初次使用时注意 ****运行角本时的命令:先切换到unix环境下,cd $oracle_home cd sqlplus cd demo 下面有两个角本建表语句。
@demobld.sqlsqlplus nanjing/nanjing @demobid.sql 直接运行角本,后面跟当前目录或者是绝对路径保存刚才的sql语句: save 命令第二次保存时要替换之前的角本 save文件名 replace把刚才保的sql重新放入 buffer 中spool on 开启记录spool off 关闭记录spool 文件名此命令会把所有的操作存在某个文件中去常见缩写:nls national language support 国家语言支持1.2. SQL的结构|DDL 数据库定义|DML 数据库管理SQL――Commit rollback|DCL 数据库控制|grant+revoke 权限管理表分为:系统表(数据字典),用户表注:知道数据字典可以更便于使用数据库。
OracleEBS_R12-OAF开发笔记(解密版)
Author:JarWang (王重东)
QQ:jarwang@ 1
Copyright(R):Jarwang
Document Control
Modify Record
日期 November 12, 2010
作者 jarwang
版本 1.0
更改参考
Approved
姓名
职位
签字
Distribute
OAF—OATrainBean ................................................................................................ 35 Create Data Table............................................................................................................ 35 Create two EO Object ..................................................................................................... 36 Create the AO Object...................................................................................................... 38 Create two VO Object..................................................................................................... 39 Create the VL Object....................................................................................................... 42 Create the AM Object ..................................................................................................... 42 Add VO Objects to AM .................................................................................................. 43 Add two Method to AM for Header ............................................................................. 43 Create the Page for Header............................................................................................ 44 Create the CO Object for Header................................................................................... 46 Run PG for Header ......................................................................................................... 47 Create the Page for Lines ............................................................................................... 47 Add a Method to AM for Lines ..................................................................................... 50 Create the CO Object for Lines ...................................................................................... 51 Implement the Currency Poplist for Lines ................................................................... 51 Add table button for Lines............................................................................................. 53 Run PG for Lines ............................................................................................................ 54 Create two VO for Preview............................................................................................ 54 Create the Page for Preview........................................................................................... 55 Create the CO Object for Preview ................................................................................. 58 Run PG for Preview........................................................................................................ 59 Create the OATrain ........................................................................................................ 59 Add OATrain to PG ....................................................................................................... 60 Add the PageButtons......................................................................................................................................................................................................................... 5
《采购与供应链管理:一个实践者的角度》读书笔记
一、供应链管理1.CEO们一致认为,供应管理最重要角色是降低产品和服务的总成本,然后是通过供应伙伴(为公司)创造新的价值源并快速推出新产品。
他们认为在未来5年,采购和供应管理应在5个领域起到重要作用:全球化、风险管控、供应战略、供应商关系、总体组织能力。
2.供应链管理涵盖三大领域:采购与供应管理、物流管理、运营管理。
3.SRM:供应商关系管理。
CRM:客户关系管理。
Oracle、SAP。
美国供应管理协会:ISM。
4.供应链管理:就是对从供应商到客户的产品流、信息流和资金流的集成管理,以达到供应链价值的最大化。
在实践操作中由三大领域构成:采购与供应管理、生产运营管理、物流管理。
5.大采购是大写的P(procurement),是指在设计阶段尽早纳入供应商。
大采购模式下,采购全面负责供应商绩效,但并不意味着供应商管理是采购部门一个部门的事,尤其是在技术驱动型公司。
两种模式注定不是大采购模式。
其一是工程师或内部客户决定一切,采购只是执行,其二是采购有了管理供应商的责任,但没有相应的权利和资源,结果只能苦苦挣扎。
所以采购部门能否完成向大采购的过渡,关键在于它能否完成两项任务:其一是选择、管理能满足公司战略需要的供应商,其二是管理、领导内部团队,共同执行供应商管理职能。
6.物流管理的对象包括运输、车队、仓储、物料处理、订单履行、物流网络设计、库存管理、供给与需求规划,以及对第三方物流服务上的管理。
二、供应商管理1. 供应商管理指标体系包括7个方面:质量quality、成本cost、交货delivery、服务service、技术technology、资产asset、员工与流程people /process,合成QCDSTAP。
前三个指标各行业通用,属于硬性指标,是供应商管理绩效指标的直接表现,后三个指标相对难于量化,是软性指标,却是保证前三个指标的根本;服务指标介于中间,是供应商增加值的重要表现。
2.质量成本cost of poor quality,COPQ.资产管理,体现供应商的总体管理水平.包括固定资产、流动资产、长期负债、短期负债等,这些都有相应的比率。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
1 三版Oracle(共五天) day1 (陆晓伟) 一.lesson 1(视频课件35.1和35.2) Oracle版本:------7i—>8—>8i—>9i—>10g(i:Internet g:网格) 1.关系数据库三要素: 1).实体(表)————class 2).属性(列)————property属性/field 3).关系(pk和fk)————对应Java中的关联关系,继承关系 pk:无序不重复,唯一,not null。(每个实体只有一个主键) fk:可以重复,可以为null ,必须指向pk, fk的值必须在pk里取 2. SQL(结构化查询语言):所有数据库的通用语言。(各别地方,不同DB有区别!) PLSQL:Oracle公司对SQL的扩展,Oracle数据库的特有语言。 SQLPLUS:Oracle公司提供的工具,用来写/发送SQL语句的。 注 SQLPLUS语句和SQL之间的比较: 相同:不区分大小写 区别:1.SQLPLUS语句可以简写,而SQL不可以; 2.SQLPLUS语句发送后不能存入Buffer,而SQL或PLSQL语句可以; 3.SQLPLUS语句后的;号不要求,而SQL必须以分号结尾。 3.创建普通用户并授权 SQL>create user 用户名 identified by 2 default tablespace users 3 temporary tablespace temp; User created. SQL>grant resource,connect to 用户名; Grant succeeded. SQL> alter user 用户名 identified by 新密码; 4.三种登陆sqlplus工具的方式: 1)SQL>sqlplus 回车 username: password: 2)SQL>sqlplus username回车 password: 3)SQL>sqlplus username/password 回车 5.SQLPLUS命令: SQL>describe(desc)+表名: 查看表的结构,可看到:columnname,是否not null,type Oracle中的几种数据类型:number(数字类型),date,varchar2(字符串类型,变长),varchar 。 SQL>list(L):显示buffer的内容,buffer属于当前的SQLPLUS,里面只能存放一条SQL命令 SQL> /<====>run(r): 运行buffer里的命令 SQL> column(col)------SQLPLUS命令 1.col[umn] 列名 heading ‘别名’ :对列进行预定义,----->此为用SQLPLUS命令为列起别名。 2.col[umn] 列名 format an或 L或$999,999.00 :对某列数据的 显示字长或格式 进行预定义。 注:an:仅适用于字符型或日期型的列,用于控制每行数据显示长度 $999,999.00:仅适用于number类型的列,控制每行数据的显示格式 L:表示根据你的数据库方言去选择货币符号,这里如果用L,则显示的为¥. 如:col last_name format a10 :表示使last_name列的数据占10个字符长度来显示。 col name heading 'na' format a10 2
注 用SQLPLUS命令col为列起别名 与 用sql命令起别名的区别: col预定义: 作用的时间长,且只要不退出sqlplus,对所有表中叫这个列名的列都生效。 sql:当次生效,且仅对当前sql的当前表中的这个列生效。 SQL> change(c):改变缓冲区中命令 1. SQL> c/old串/new串 2. SQL> 1 select * (当命令得某一行中需要改动较多时,使用该命令来更改某一具体行) 3. SQL> edit(ed)------>vi:unix系统 ed------>记事本:windows SQL> save :buffer----->file 将buffer里的内容保存出去: 1.new ------->save filename :保存并新建 2.override---->save filename replace(rep) :保存并覆盖 SQL> get filename:file------>buffer 把文件的内容导回缓冲区 SQL> start(@) filename ======get + run(/) 把文件内容导入缓冲区并且执行。 SQL> spool filename------>spool off:抓屏,将抓到的所有内容都保存到filename文件中 二.lesson 2 1.order by子句: 排序 select id,last_name,dept_id from s_emp 1)order by dept_id; order by title; //注:可以不按照要查询的列进行排序,只要表中有的列就可以。 2)order by last_name,dept_id;先按名字升序排,名字相同再按dept_id升序排。不指明时默认按照升序(ASC)排列 3)order by last_name desc; order by dept_id,last_name desc; //dept_id升序,last_name降序 4)null //注:null在oracle里是最大的值。 5)order by 2; <===> order by last_name //注:这里的2,表示select里面的第二列。 6)按列的别名排序 select id,last_name name from s_emp order by NAME; 2.where子句:条件判断 select id,last_name,dept_id,start_date from s_emp 1)where dept_id=41; where last_name='Smith'; ---->严格区分大小写 where start_date='08-mar-90';---->必须这么写,dd-mon-yy是Oracle数据库中默认的日期格式。 2)where salary>1000; 3)关键字:between --- and--- where dept_id between 41 and 45; ---包括边界值 where dept_id between 45 and 41; ---无语法错误,但查不出结果!注:必须值小的在前,反了,将查不出记录。 4)where dept_id in(41,43,45); ----枚举,用in 5)where commission_pct=null;----查不出记录,错误!因为表达式中出现null,结果一定为null! where commission_pct is null;-----正确!! where commission_pct is not null; 6)where last_name like 'S%';----模糊查询 unix中通配符: *(表0到多个) ?(有且仅有一个) oracle中通配符: %(表0到多个) _(有且仅有一个) 例:查出last_name是以'S_'开始的: where last_name like 'S_%'; ----> error!!! where last_name like 'S\_%' escape '\'; ---->right!!! 注:oracle中没定义固定的转义字符,需要用转义字符时,须用escape指明谁是转义字符!!! 3
7)非: != <> not between…and not in not like is not null 8)执行优先级:括号>and > or && > ||
Oracle day2 一.lesson 3(day2 上午 视频课件36.1) 单行函数(Single Row Function):应用于每一个值,并且产生每一个结果。 1.针对varchar2型的:(LOWER、upper、initcap单词首字母大写、concat、substr、length、nvl) 1) 处理空值函数 nvl('hello','world') --等价---> 'hello' (由于hello串永远都不为null,所以等价于‟hello‟) nvl(null,'world') --等价---> 'world' 2) select id,last_name,dept_id from s_emp where lower(last_name)='smith'; ---LOWER应用很多! 3) select id,concat(last_name,first_name),dept_id from s_emp; concat(last_name,first_name)--->result1; concat(result1,title); ----等价---> concat(concat(last_name,first_name),title); 注:||连接多个列的情况较常用,因为concat连接多个串时需要函数的嵌套。 4)select substr('String',-4,3) from dual; //显示结果:rin ---SUBSTR应用很多! 注:当所查的列不在任何表中或不清楚它能从哪个表中查到时,就可以用dual(dummy table)盲(哑)表,它的存在是为了维护select的完整性 例:substr可辅助进行模糊查询 select id,last_name,dept_id from s_emp where last_name like 'S%'; ---等价于--> where substr(last_name,1,1)='S'; 2.针对number型的: round:四舍五入的截取数字值 Round(45.923,2)-->45.92 Round(45.923,0)-->46 Round(45.923,-1)-->50 trunc:直接截取数字值 trunc(45.923,2)-->45.92 trunc(45.923,0)-->45 trunc(45.923,-1)-->40 3.针对date型的: months_between(‟01-SEP-95‟,‟11-jan-94‟) ------>19.774194 :两个日期之间的月份数 add_months (‟11-JAN-94‟,6)----->‟11-JUL-94‟:Add calendar months to date. next_day(‟19-jun-08‟,Friday) : 接下来第一个星期五的日期(从当前天往后查,找第一个符合的) last_day(‟01-sep-95‟)---->‟30-sep-95‟ :本月的最后一天的日期。 Round:四舍五入的截取日期 round(‟25-MAY-95‟,‟MONTH‟)---->01-JUN-95 round(‟25-MAY-95‟,‟YEAR‟) ---->01-JAN-95 Trunc :直接截取日期 trunc(‟25-MAY-95‟,‟MONTH‟)---->01-MAY-95 trunc(‟25-MAY-95‟,‟YEAR‟) ---->01-JAN-95 1) SQL> select sysdate from dual; 查看当前系统时间 SYSDATE -------------- 22-7月 -09 2)SQL> select to_char(sysdate,'dd-mon-yyyy,hh24:mi:ss pm') sdate from dual;//设置显示格式 SDATE ---------------------------------------- 22-7月 -2009,09:58:28 上午 注:Oracle中默认的日期显示格式是DD-MON-YY。 3)标准的日期格式: 年: yy 08 yyyy 2008