Home Database Mysql Tutorial SqlServer到Oracle数据库转换手记

SqlServer到Oracle数据库转换手记

Jun 07, 2016 pm 03:25 PM
oracle sqlserver Notes database Convert

最近做了些数据库转换工作,主要是从Sql Server转换到Oracle,过程中遇到很多问题,现进行一个小小总结,方便有同样需求的朋友们。 需要对数据库结构、数据、自定义函数、存储过程等数据库元素进行转换,由于Sql Server和Oracle数据库语言本身的差异非常大,

        最近做了些数据库转换工作,主要是从Sql Server转换到Oracle,过程中遇到很多问题,现进行一个小小总结,方便有同样需求的朋友们。

        需要对数据库结构、数据、自定义函数、存储过程等数据库元素进行转换,由于Sql Server和Oracle数据库语言本身的差异非常大,所以自定义函数和存储过程的转换是比较困难的一件事情,市面上也很少有这方面的工具,几乎都想直接写工具了,后来却找到了个国外的一个叫做“SwissSQL-SQL Server To Oracle”这样的工具,此工具可以在http://www.swissql.com/站点上下载,使用方法有两种,一种是转换TSQL脚本到PLSQL,一种是通过JDBC连接到SQLServer数据库进行转换,转换后的结果都保存为PLSQL脚本,要导入Oracle需要运行这些脚本。此软件是用Java语言编写在安装之前必须先安装JDK,在试用过程中发现此工具存在这么几个问题:

1、此工具在转换数据结构的过程中把varchar的数据类型都转换成varchar2(1)了而不管原谅数据有多长统一都转换成1个长度,我不知道这么简单的BUG有没有其他设置的地方,反正后来我们没用它转数据结构也就没怎么研究了。

2、此工具为试用版本,我们也没找到注册版,而试用版只能前后转换共2000行SQL语句,而要购买这个软件也不太实际,费用高不说,还是外国的买起来也麻烦,软件为转换这么几个存储过程去耗费这么大的资金在我们这些用盗版的人看来是不可取的,我们的数据库对象那么多,显然这是不好办的问题,那么能否用欺骗的手法蒙混过关呢?下面就是具体的欺骗手法了:
        -记得以前用过一个软件叫着“完美卸载”此软件可以记录安装程序时对磁盘进行的更改,有了这个我们就可以安装软件的时候记录好此软件对磁盘所写入的文件,看看有什么异样这样我们就能理解共享软件在那个文件写入了注册信息。
        -通过跟踪发现在安装软件的时候,安装程序除了对安装目录写入信息和少量的注册表信息外没有对磁盘做任何更改,别急,我们继续跟踪,跟踪到第一次运行软件的时候,就有了异样,发现此软件在Windows目录下写入了SqlServer到Oracle数据库转换手记这个文件,赶忙备份此文件,转换了几行语句后,关闭软件,果然此文件再次被修改,这就说明很有可能此文件就是记录的软件试用的行数。当我们第二次使用的时候把备份的文件覆盖了原文件,但此事软件所有按钮都禁用了,说明软件还有其他的地方可以判断用户是否使用过软件。重新安装软件(其实就是把安装目录里的文件重置一下),结果又可以使用2000行了。这就是软件欺骗的全部过程,也是可当作破解软件的土办法,只是麻烦一点的是需要先备份安装目录和那个dll文件,注意那个dll文件不能通用,必须要程序生成的本机的dll文件。当快要用完试用行数的时候通过覆盖文件的方式欺骗软件,从而可以继续试用,就这么简单。

    另外在转换数据库的过程中应该还要注意以下几个问题:
        -在Oracle数据库中命名不能大于30个英文字符,无论是表名、存储过程名等等,统统不能大于30个字符。
        -在Oracle数据库中,存储过程的定义更侠义一些,而不像SqlServer那样开放。特别像返回结果集这些操作上存在很多差异,在SQLServer可以直接试用select语句返回结果集,而Oracle只能把存储过程封装到包中设置Out参数的Cursor数据类型来达到返回结果集的目的,在存储过程内部不能直接试用Select语句返回结果集,很是不便。
        -在使用单纯的SQL语句的时候,如果是多条语句,调用Oracle数据库就必须封装在begin/end语句块中。
        -手动对Oracle数据库查询时可以选用PL/SQL Developer这个工具,蛮好用的。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

How to solve the problem of closing oracle cursor How to solve the problem of closing oracle cursor Apr 11, 2025 pm 10:18 PM

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

How to create oracle dynamic sql How to create oracle dynamic sql Apr 12, 2025 am 06:06 AM

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values ​​to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

How to create cursors in oracle loop How to create cursors in oracle loop Apr 12, 2025 am 06:18 AM

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

What to do if the oracle can't be opened What to do if the oracle can't be opened Apr 11, 2025 pm 10:06 PM

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

How to read the oracle awr report How to read the oracle awr report Apr 11, 2025 pm 09:45 PM

An AWR report is a report that displays database performance and activity snapshots. The interpretation steps include: identifying the date and time of the activity snapshot. View an overview of activities and resource consumption. Analyze session activities to find session types, resource consumption, and waiting events. Find potential performance bottlenecks such as slow SQL statements, resource contention, and I/O issues. View waiting events, identify and resolve them for performance. Analyze latch and memory usage patterns to identify memory issues that are causing performance issues.

How to use triggers for oracle How to use triggers for oracle Apr 11, 2025 pm 11:57 PM

Triggers in Oracle are stored procedures used to automatically perform operations after a specific event (insert, update, or delete). They are used in a variety of scenarios, including data verification, auditing, and data maintenance. When creating a trigger, you need to specify the trigger name, association table, trigger event, and trigger time. There are two types of triggers: the BEFORE trigger is fired before the operation, and the AFTER trigger is fired after the operation. For example, the BEFORE INSERT trigger ensures that the age column of the inserted row is not negative.

See all articles