国产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ù)庫(kù)基本上能實(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沒(méi)有自動(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)度來(lái)定, 如果定義的自動(dòng)增長(zhǎng)的序列號(hào) NUMBER(6) , 最大值為999999
????INSERT 語(yǔ)句插入這個(gè)字段值為: 序列號(hào)的名稱.NEXTVAL

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

3.??翻頁(yè)的SQL語(yǔ)句的處理
????MYSQL處理翻頁(yè)的SQL語(yǔ)句比較簡(jiǎn)單,用LIMIT 開(kāi)始位置, 記錄個(gè)數(shù);PHP里還可以用SEEK定位到結(jié)果
集的位置。
????ORACLE處理翻頁(yè)的SQL語(yǔ)句就比較繁瑣了。每個(gè)結(jié)果集只有一個(gè)ROWNUM字段標(biāo)明它的位置, 并且只能
用ROWNUM80。
????以下是經(jīng)過(guò)分析后較好的兩種ORACLE翻頁(yè)SQL語(yǔ)句( ID是唯一關(guān)鍵字的字段名 ):
????語(yǔ)句一:
????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 ??
????語(yǔ)句二:
????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ù)庫(kù)
的系統(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來(lái)定義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ù)庫(kù)的工作完成后請(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)

What is Impossible Cloud Network (ICNT)? How? A comprehensive introduction to the ICN project that Binance will launch soon What is Impossible Cloud Network (ICNT)? How? A comprehensive introduction to the ICN project that Binance will launch soon Jul 07, 2025 pm 07:06 PM

Contents 1. What is ICN? 2. ICNT latest updates 3. Comparison and economic model between ICN and other DePIN projects and economic models 4. Conclusion of the next stage of the DePIN track At the end of May, ICN (ImpossibleCloudNetwork) @ICN_Protocol announced that it had received strategic investment in NGPCapital with a valuation of US$470 million. Many people's first reaction was: "Has Xiaomi invested in Web3?" Although this was not Lei Jun's direct move, the one who had bet on Xiaomi, Helium, and WorkFusion

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.

Calculating Database and Table Sizes in MySQL Calculating Database and Table Sizes in MySQL Jul 06, 2025 am 02:41 AM

To view the size of the MySQL database and table, you can query the information_schema directly or use the command line tool. 1. Check the entire database size: Execute the SQL statement SELECTtable_schemaAS'Database',SUM(data_length index_length)/1024/1024AS'Size(MB)'FROMinformation_schema.tablesGROUPBYtable_schema; you can get the total size of all databases, or add WHERE conditions to limit the specific database; 2. Check the single table size: use SELECTta

Setting up asynchronous primary-replica replication in MySQL Setting up asynchronous primary-replica replication in MySQL Jul 06, 2025 am 02:52 AM

To set up asynchronous master-slave replication for MySQL, follow these steps: 1. Prepare the master server, enable binary logs and set a unique server-id, create a replication user and record the current log location; 2. Use mysqldump to back up the master library data and import it to the slave server; 3. Configure the server-id and relay-log of the slave server, use the CHANGEMASTER command to connect to the master library and start the replication thread; 4. Check for common problems, such as network, permissions, data consistency and self-increase conflicts, and monitor replication delays. Follow the steps above to ensure that the configuration is completed correctly.

Implementing Transactions and Understanding ACID Properties in MySQL Implementing Transactions and Understanding ACID Properties in MySQL Jul 08, 2025 am 02:50 AM

MySQL supports transaction processing, and uses the InnoDB storage engine to ensure data consistency and integrity. 1. Transactions are a set of SQL operations, either all succeed or all fail to roll back; 2. ACID attributes include atomicity, consistency, isolation and persistence; 3. The statements that manually control transactions are STARTTRANSACTION, COMMIT and ROLLBACK; 4. The four isolation levels include read not committed, read submitted, repeatable read and serialization; 5. Use transactions correctly to avoid long-term operation, turn off automatic commits, and reasonably handle locks and exceptions. Through these mechanisms, MySQL can achieve high reliability and concurrent control.

Handling character sets and collations issues in MySQL Handling character sets and collations issues in MySQL Jul 08, 2025 am 02:51 AM

Character set and sorting rules issues are common when cross-platform migration or multi-person development, resulting in garbled code or inconsistent query. There are three core solutions: First, check and unify the character set of database, table, and fields to utf8mb4, view through SHOWCREATEDATABASE/TABLE, and modify it with ALTER statement; second, specify the utf8mb4 character set when the client connects, and set it in connection parameters or execute SETNAMES; third, select the sorting rules reasonably, and recommend using utf8mb4_unicode_ci to ensure the accuracy of comparison and sorting, and specify or modify it through ALTER when building the library and table.

Connecting to MySQL Database Using the Command Line Client Connecting to MySQL Database Using the Command Line Client Jul 07, 2025 am 01:50 AM

The most direct way to connect to MySQL database is to use the command line client. First enter the mysql-u username -p and enter the password correctly to enter the interactive interface; if you connect to the remote database, you need to add the -h parameter to specify the host address. Secondly, you can directly switch to a specific database or execute SQL files when logging in, such as mysql-u username-p database name or mysql-u username-p database name

How does Oracle manage transaction commits and rollbacks using redo and undo mechanisms? How does Oracle manage transaction commits and rollbacks using redo and undo mechanisms? Jul 08, 2025 am 12:16 AM

Oracleensurestransactiondurabilityandconsistencyusingredoforcommitsandundoforrollbacks.Duringacommit,Oraclegeneratesacommitrecordintheredologbuffer,markschangesaspermanentinredologs,andupdatestheSCNtoreflectthecurrentdatabasestate.Forrollbacks,Oracle

See all articles