从MySQL迁移到Oracle_MySQL
bitsCN.com
1. 自动增长的数据类型处理
MYSQL有自动增长的数据类型,插入记录时不用操作此字段,会自动获得数据值。ORACLE没有自动增长的数据类型,需要建立一个自动增长的序列号,插入记录时要把序列号的下一个值赋于此字段。
CREATE SEQUENCE 序列号的名称 (最好是表名+序列号标记) INCREMENT BY 1 START WITH 1 MAXVALUE 99999 CYCLE NOCACHE;
INSERT 语句插入这个字段值为: 序列号的名称.NEXTVAL
2. 单引号的处理
MYSQL里可以用双引号包起字符串,ORACLE里只可以用单引号包起字符串。在插入和修改字符串前必须做单引号的替换:把所有出现的一个单引号替换成两个单引号。当然你如果使用 Convert Mysql to Oracle 工具就不用考虑这个问题
3.长字符串的处理
在ORACLE中,INSERT和UPDATE时最大可操作的字符串长度小于等于4000个单字节, 如果要插入更长的字符串, 请考虑字段用CLOB类型,方法借用ORACLE里自带的DBMS_LOB程序包。插入修改记录前一定要做进行非空和长度判断,不能为空的字段值和超出长度字段值都应该提出警告,返回上次操作。
4. 翻页的SQL语句的处理
MYSQL处理翻页的SQL语句比较简单,用LIMIT 开始位置, 记录个数。ORACLE处理翻页的SQL语句就比较繁琐了。每个结果集只有一个ROWNUM字段标明它的位置, 并且只能用ROWNUM80。
以下是经过分析后较好的两种ORACLE翻页SQL语句( ID是唯一关键字的字段名 ):
语句一:
SELECT ID, [FIELD_NAME,...] FROM TABLE_NAME WHERE ID IN ( SELECT ID FROM (SELECT ROWNUM AS NUMROW, ID FROM TABLE_NAME WHERE 条件1 ORDER BY 条件2) WHERE NUMROW > 80 AND NUMROW
语句二:
SELECT * FROM (( SELECT ROWNUM AS NUMROW, c.* from (select [FIELD_NAME,...] FROM TABLE_NAME WHERE 条件1 ORDER BY 条件2) c) WHERE NUMROW > 80 AND NUMROW
5. 日期字段的处理
MYSQL日期字段分DATE和TIME两种,ORACLE日期字段只有DATE,包含年月日时分秒信息,用当前数据库的系统时间为SYSDATE, 精确到秒。
日期字段的数学运算公式有很大的不同。MYSQL找到离当前时间7天用 DATE_FIELD_NAME > SUBDATE(NOW(),INTERVAL 7 DAY)ORACLE找到离当前时间7天用 DATE_FIELD_NAME >SYSDATE - 7;
6. 字符串的模糊比较
MYSQL里用 字段名 like '%字符串%',ORACLE里也可以用 字段名 like '%字符串%' 但这种方法不能使用索引, 速度不快,用字符串比较函数 instr(字段名,'字符串')>0 会得到更精确的查找结果。
7. 空字符的处理
MYSQL的非空字段也有空的内容,ORACLE里定义了非空字段就不容许有空的内容。按MYSQL的NOT NULL来定义ORACLE表结构, 导数据的时候会产生错误。因此导数据时要对空字符进行判断,如果为NULL或空字符,需要把它改成一个空格的字符串。
作者“zone8089653的专栏”
bitsCN.com
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The Apple serial number beginning with d indicates that the phone was produced by Chengdu Foxconn. The serial number of an Apple mobile phone has its own meaning. The first digit represents the production place, the second and third digits represent the production line, the fourth and fifth digits represent the production year and cycle, and the sixth, seventh and eighth digits are the unique identification of the product. symbol, the ninth and tenth digits represent the model, the eleventh and twelfth digits represent the color and capacity. The first one in the serial number represents the production place: 1. F represents Zhengzhou, Henan; 2. D represents Chengdu, Sichuan; 3. C represents Shenzhen, Guangdong; 4. G0 represents Shanghai Pegatron; 5. G6 represents Shenzhen Foxconn’s new production line.

The serial number of an Apple phone starting with h should be an Apple phone produced in Vietnam. The beginning of the serial number of an Apple phone represents different production areas and you can also tell what version it is, which is one of the very important information. Where is the serial number of the Apple mobile phone starting with h from? Answer: The h value is produced in Vietnam. 1. Apple has moved part of its production lines to Vietnam in recent years. 2. If a user purchases an Apple mobile phone and finds that the relevant serial number begins with h, it is produced in Vietnam. 3. Different letters starting with letters indicate different production areas. Among them, those starting with F are produced by Zhengzhou Foxconn. 4. Those starting with C are produced by Shenzhen Foxconn, those starting with D are produced by Chengdu Foxconn, and those starting with G are produced by Shanghai Pegatron. 5. It is recommended not to disclose the program of your device easily.

The hard disk serial number can be checked through the hard disk packaging box or the hard disk casing, or in the Win11 system. However, some users do not know the method. This article is a method for querying the Win11 hard disk serial number brought to you by this site. What is the number of digits in a hard drive serial number? A computer hard drive serial number is a unique identifier that identifies a specific hard drive. It is provided by the hard drive manufacturer and cannot be modified by the user. The hard disk serial number usually contains 10 to 20 digits and letters, and of course generally consists of 12 digits. It can be used to record hard disk parameters such as hard disk capacity, loading mode, and read and write speeds. In computer systems, hard drive serial numbers are usually used to identify and distinguish different hard drives, and in some cases are used for password protection, software authorization, etc. pass

Pinduoduo software provides a lot of good products, you can buy them anytime and anywhere, and the quality of each product is strictly controlled, every product is genuine, and there are many preferential shopping discounts, allowing everyone to shop online Simply can not stop. Enter your mobile phone number to log in online, add multiple delivery addresses and contact information online, and check the latest logistics trends at any time. Product sections of different categories are open, search and swipe up and down to purchase and place orders, and experience convenience without leaving home. With the online shopping service, you can also view all purchase records, including the goods you have purchased, and receive dozens of shopping red envelopes and coupons for free. Now the editor has provided Pinduoduo users with a detailed online way to view purchased product records. method. 1. Open your phone and click on the Pinduoduo icon.

The iPhone serial number is a series of numbers and letters that uniquely identifies each iPhone device. The serial number contains a lot of information, and the letters at the beginning represent different meanings. Let’s analyze them one by one below. The first letter represents the manufacturer information of the iPhone device: A represents iPhone manufactured by Foxconn (Hon Hai Precision Industry Co., Ltd.), which is one of the most common manufacturers of iPhone; C represents Pegatron (Pegatron Precision Industry Co., Ltd. )made

When it comes to Excel and serial numbers, you may be able to handle them even while you sleep. You just need to enter 1 and drag the column down to automatically fill in the serial numbers in all cells below it. But what about Word and serial numbers? Well, most of us would frown at this advice because it's definitely not straightforward when it comes to Word. But is this impossible? Well, when did we ever say the word impossible? This article is all about autofilling serial numbers in Word documents. So let’s jump right into the article, shall we? Insert and Populate Serial Number Column in Microsoft Word Step 1: First, if your table doesn’t already have a serial number column, let’s insert one. Click on the left side of the table

Risks of leaking the mobile phone serial number: 1. Warranty issues; 2. The phone is locked; 3. Information leakage; 4. Malware attacks, etc. Detailed introduction: 1. Warranty issues. If the mobile phone serial number is leaked to unauthorized third parties, these third parties may use this information to impersonate mobile phone users and defraud the mobile phone’s warranty service; 2. The mobile phone is locked. In some cases, Under the circumstances, leaking the mobile phone serial number may cause the phone to be maliciously locked. For example, some hackers may use this information to lock the user's phone to obtain ransom or expose the user's information, etc.

How to Find Your Apple Watch Serial Number In Settings Open the Settings app on your Apple Watch Now tap on General → About Slide down to find your serial number If your Apple Watch is not turning on, you can also head to the Watch app on your iPhone and tap on General → Find the serial number under About (as long as the watch is still paired with your iPhone). Find your printed Apple Watch serial number. For the original Apple Watch, the serial number is printed on the back of the watch. For Apple Watch Series 1 and newer, it's inside the band slot, as shown below. Other options you'll find below
