国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 php手冊(cè) MYSQL到ORACLE程序遷移的注意事項(xiàng)(轉(zhuǎn)載)

MYSQL到ORACLE程序遷移的注意事項(xiàng)(轉(zhuǎn)載)

Jun 21, 2016 am 09:12 AM
mysql nbsp oracle select

mysql|oracle|程序

MYSQL到ORACLE程序遷移的注意事項(xiàng)?????????????

????????????????????????????????????2001-09


????有很多應(yīng)用項(xiàng)目, 剛起步的時(shí)候用MYSQL數(shù)據(jù)庫基本上能實(shí)現(xiàn)各種功能需求,隨著應(yīng)用用戶的增多,
數(shù)據(jù)量的增加,MYSQL漸漸地出現(xiàn)不堪重負(fù)的情況:連接很慢甚至宕機(jī),于是就有把數(shù)據(jù)從MYSQL遷到
ORACLE的需求,應(yīng)用程序也要相應(yīng)做一些修改。本人總結(jié)出以下幾點(diǎn)注意事項(xiàng),希望對(duì)大家有所幫助。

1. 自動(dòng)增長(zhǎng)的數(shù)據(jù)類型處理
????MYSQL有自動(dòng)增長(zhǎng)的數(shù)據(jù)類型,插入記錄時(shí)不用操作此字段,會(huì)自動(dòng)獲得數(shù)據(jù)值。
ORACLE沒有自動(dòng)增長(zhǎng)的數(shù)據(jù)類型,需要建立一個(gè)自動(dòng)增長(zhǎng)的序列號(hào),插入記錄時(shí)要把序列號(hào)的下一個(gè)
值賦于此字段。

????CREATE SEQUENCE 序列號(hào)的名稱 (最好是表名+序列號(hào)標(biāo)記) INCREMENT BY 1??START??WITH??1
MAXVALUE??99999??CYCLE??NOCACHE;
????其中最大的值按字段的長(zhǎng)度來定, 如果定義的自動(dòng)增長(zhǎng)的序列號(hào) NUMBER(6) , 最大值為999999
????INSERT 語句插入這個(gè)字段值為: 序列號(hào)的名稱.NEXTVAL

2. 單引號(hào)的處理
????MYSQL里可以用雙引號(hào)包起字符串,ORACLE里只可以用單引號(hào)包起字符串。在插入和修改字符串
前必須做單引號(hào)的替換:把所有出現(xiàn)的一個(gè)單引號(hào)替換成兩個(gè)單引號(hào)。

3.??翻頁的SQL語句的處理
????MYSQL處理翻頁的SQL語句比較簡(jiǎn)單,用LIMIT 開始位置, 記錄個(gè)數(shù);PHP里還可以用SEEK定位到結(jié)果
集的位置。
????ORACLE處理翻頁的SQL語句就比較繁瑣了。每個(gè)結(jié)果集只有一個(gè)ROWNUM字段標(biāo)明它的位置, 并且只能
用ROWNUM80。
????以下是經(jīng)過分析后較好的兩種ORACLE翻頁SQL語句( ID是唯一關(guān)鍵字的字段名 ):
????語句一:
????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
4. 長(zhǎng)字符串的處理
????長(zhǎng)字符串的處理ORACLE也有它特殊的地方。INSERT和UPDATE時(shí)最大可操作的字符串長(zhǎng)度小于等于
4000個(gè)單字節(jié), 如果要插入更長(zhǎng)的字符串, 請(qǐng)考慮字段用CLOB類型,方法借用ORACLE里自帶的DBMS_LOB程序
包。插入修改記錄前一定要做進(jìn)行非空和長(zhǎng)度判斷,不能為空的字段值和超出長(zhǎng)度字段值都應(yīng)該提出警告,
返回上次操作。

5.??日期字段的處理
????MYSQL日期字段分DATE和TIME兩種,ORACLE日期字段只有DATE,包含年月日時(shí)分秒信息,用當(dāng)前數(shù)據(jù)庫
的系統(tǒng)時(shí)間為SYSDATE, 精確到秒,或者用字符串轉(zhuǎn)換成日期型函數(shù)TO_DATE(‘2001-08-01’,’YYYY-MM-DD’)
年-月-日 24小時(shí):分鐘:秒 的格式Y(jié)YYY-MM-DD HH24:MI:SS TO_DATE()還有很多種日期格式, 可以參看
ORACLE DOC.
????日期型字段轉(zhuǎn)換成字符串函數(shù)TO_CHAR(‘2001-08-01’,’YYYY-MM-DD HH24:MI:SS’)

????日期字段的數(shù)學(xué)運(yùn)算公式有很大的不同。
???????MYSQL找到離當(dāng)前時(shí)間7天用
????DATE_FIELD_NAME > SUBDATE((NOW(),INTERVAL 7 DAY)
?????ORACLE找到離當(dāng)前時(shí)間7天用
????DATE_FIELD_NAME >SYSDATE - 7;

6.??空字符的處理
????MYSQL的非空字段也有空的內(nèi)容,ORACLE里定義了非空字段就不容許有空的內(nèi)容。
????按MYSQL的NOT NULL來定義ORACLE表結(jié)構(gòu), 導(dǎo)數(shù)據(jù)的時(shí)候會(huì)產(chǎn)生錯(cuò)誤。因此導(dǎo)數(shù)據(jù)時(shí)要對(duì)空字符進(jìn)行判
斷,如果為NULL或空字符,需要把它改成一個(gè)空格的字符串。

7. 字符串的模糊比較
???MYSQL里用????????字段名 like '%字符串%'
???ORACLE里也可以用????字段名 like '%字符串%'????????但這種方法不能使用索引, 速度不快
???用字符串比較函數(shù)????????instr(字段名,'字符串')>0????????會(huì)得到更精確的查找結(jié)果????

8. 程序和函數(shù)里,操作數(shù)據(jù)庫的工作完成后請(qǐng)注意結(jié)果集和指針的釋放。


有興趣可以看MYSQL管理員指南????????????



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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

How to add the MySQL bin directory to the system PATH How to add the MySQL bin directory to the system PATH Jul 01, 2025 am 01:39 AM

To add MySQL's bin directory to the system PATH, it needs to be configured according to the different operating systems. 1. Windows system: Find the bin folder in the MySQL installation directory (the default path is usually C:\ProgramFiles\MySQL\MySQLServerX.X\bin), right-click "This Computer" → "Properties" → "Advanced System Settings" → "Environment Variables", select Path in "System Variables" and edit it, add the MySQLbin path, save it and restart the command prompt and enter mysql--version verification; 2.macOS and Linux systems: Bash users edit ~/.bashrc or ~/.bash_

What is Ethereum cross-chain bridge? How to achieve asset transfer? What is Ethereum cross-chain bridge? How to achieve asset transfer? Jul 02, 2025 pm 10:57 PM

Blockchain technology has spawned many independent networks, such as Ethereum, Binance Smart Chain, Polygon, etc. Each network has its own unique design and protocol. However, this independence also presents the challenge of difficult assets and information flowing freely between different chains. For example, ERC-20 tokens on Ethereum cannot be used directly on the Polygon network. In order to solve this isolation problem, cross-chain bridges emerged and became the key infrastructure to connect different blockchain networks.

How to install MySQL on Windows 11 How to install MySQL on Windows 11 Jun 29, 2025 am 01:47 AM

The key steps for installing MySQL on Windows 11 are as follows: 1. Download the correct version, select the Windows MSI installation package and ensure that the system is 64-bit; 2. Select the "Custom" mode during installation, add MySQLServer and set the appropriate installation path; 3. Run the configuration wizard, select the "ServerComputer" configuration type, set the root password, and select the automatic startup method; 4. After the test installation is successful, if the prompt command is unavailable, add the MySQL bin directory to the system PATH environment variable. Follow these steps to complete the installation and configuration smoothly.

Resetting the root password for MySQL server Resetting the root password for MySQL server Jul 03, 2025 am 02:32 AM

To reset the root password of MySQL, please follow the following steps: 1. Stop the MySQL server, use sudosystemctlstopmysql or sudosystemctlstopmysqld; 2. Start MySQL in --skip-grant-tables mode, execute sudomysqld-skip-grant-tables&; 3. Log in to MySQL and execute the corresponding SQL command to modify the password according to the version, such as FLUSHPRIVILEGES;ALTERUSER'root'@'localhost'IDENTIFIEDBY'your_new

Handling NULL Values in MySQL Columns and Queries Handling NULL Values in MySQL Columns and Queries Jul 05, 2025 am 02:46 AM

When handling NULL values ??in MySQL, please note: 1. When designing the table, the key fields are set to NOTNULL, and optional fields are allowed NULL; 2. ISNULL or ISNOTNULL must be used with = or !=; 3. IFNULL or COALESCE functions can be used to replace the display default values; 4. Be cautious when using NULL values ??directly when inserting or updating, and pay attention to the data source and ORM framework processing methods. NULL represents an unknown value and does not equal any value, including itself. Therefore, be careful when querying, counting, and connecting tables to avoid missing data or logical errors. Rational use of functions and constraints can effectively reduce interference caused by NULL.

Analyzing the MySQL Slow Query Log to Find Performance Bottlenecks Analyzing the MySQL Slow Query Log to Find Performance Bottlenecks Jul 04, 2025 am 02:46 AM

Turn on MySQL slow query logs and analyze locationable performance issues. 1. Edit the configuration file or dynamically set slow_query_log and long_query_time; 2. The log contains key fields such as Query_time, Lock_time, Rows_examined to assist in judging efficiency bottlenecks; 3. Use mysqldumpslow or pt-query-digest tools to efficiently analyze logs; 4. Optimization suggestions include adding indexes, avoiding SELECT*, splitting complex queries, etc. For example, adding an index to user_id can significantly reduce the number of scanned rows and improve query efficiency.

Performing logical backups using mysqldump in MySQL Performing logical backups using mysqldump in MySQL Jul 06, 2025 am 02:55 AM

mysqldump is a common tool for performing logical backups of MySQL databases. It generates SQL files containing CREATE and INSERT statements to rebuild the database. 1. It does not back up the original file, but converts the database structure and content into portable SQL commands; 2. It is suitable for small databases or selective recovery, and is not suitable for fast recovery of TB-level data; 3. Common options include --single-transaction, --databases, --all-databases, --routines, etc.; 4. Use mysql command to import during recovery, and can turn off foreign key checks to improve speed; 5. It is recommended to test backup regularly, use compression, and automatic adjustment.

Paginating Results with LIMIT and OFFSET in MySQL Paginating Results with LIMIT and OFFSET in MySQL Jul 05, 2025 am 02:41 AM

MySQL paging is commonly implemented using LIMIT and OFFSET, but its performance is poor under large data volume. 1. LIMIT controls the number of each page, OFFSET controls the starting position, and the syntax is LIMITNOFFSETM; 2. Performance problems are caused by excessive records and discarding OFFSET scans, resulting in low efficiency; 3. Optimization suggestions include using cursor paging, index acceleration, and lazy loading; 4. Cursor paging locates the starting point of the next page through the unique value of the last record of the previous page, avoiding OFFSET, which is suitable for "next page" operation, and is not suitable for random jumps.

See all articles