Script: To remove Chained Rows from a Table (Doc ID 1019556.6)
Script: To remove Chained Rows from a Table (Doc ID 1019556.6) Abstract |
|
---|---|
This script will remove chained rows from a table and is maintained for backward compatibility purposes only. If running Oracle8i and up, it is recommended to use the "alter table ... move" command to reorganize a table to remove chained rows. Please see Note:110246.1 - How to reorganize tables, for complete syntax. |
|
Product Name, Product Version |
Oracle Server, 7.3.4 to 9.2.0 |
Platform | Platform Independent |
Date Created | 10-Jul-1996 |
Instructions | |
Execution Environment: SQL, SQL*Plus Access Privileges: Requires CREATE TABLE, INSERT/SELECT/DELETE privileges on the chained table. Usage: sqlplus user/ |
|
Description | |
The following script was adapted from a demo script which created a table with chained rows. It then showed how to eliminate the chaining. As modified, this script performs the following actions: 1. Accepts a table name (which has chained rows) 2. ANALYZEs the table and stores the rows in CHAINED_ROWS 3. CREATEs AS SELECT a temporary table with the chained rows 4. DELETEs the rows from the original table 5. INSERTs the rows from the temp table back into the original This script will NOT help if the rows of the table are actually too large to fit in a single block. All new scripts should be tested before use in a critical environment, but since this script actually modifies data in your database, TEST THIS SCRIPT ON A NON-PRODUCTION SERVER OR TABLE FIRST. |
|
References | |
|
|
Script | |
SET ECHO off REM NAME: TFSCHAIN.SQL REM USAGE:"@path/tfschain chained_table" REM -------------------------------------------------------------------------- REM REQUIREMENTS: REM CREATE TABLE, INSERT/SELECT/DELETE on the chained table REM The following script was adapted from a demo script which created a REM table with chained rows, then showed how to eliminate the chaining. REM As modified, this script performs the following actions: REM REM 1. Accepts a table name (which has chained rows) REM 2. ANALYZEs the table and store the rows in CHAINED_ROWS REM 3. CREATEs AS SELECT a temporary table with the chained rows REM 4. DELETEs the rows from the original table REM 5. INSERTs the rows from the temp table back into the original REM REM This script will NOT work if the rows of the table are actually REM too large to fit in a single block. REM -------------------------------------------------------------------------- REM Main text of script follows: set ECHO off ACCEPT chaintabl PROMPT 'Enter the table with chained rows: ' drop table chaintemp; drop table chained_rows; start $ORACLE_HOME/rdbms/admin/utlchain set ECHO OFF REM ********************************************** REM ********************************************** REM ANALYZE table to locate chained rows analyze table &chaintabl list chained rows into chained_rows; REM ********************************************** REM ********************************************** REM CREATE Temporary table with the chained rows create table chaintemp as select * from &chaintabl where rowid in (select head_rowid from chained_rows); REM ********************************************** REM ********************************************** REM DELETE the chained rows from the original table delete from &chaintabl where rowid in (select head_rowid from chained_rows); REM ********************************************** REM ********************************************** REM INSERT the formerly chained rows back into table insert into &chaintabl select * from chaintemp; REM ********************************************** REM ********************************************** REM DROP the temporary table drop table chaintemp; ============== Sample Output: ============== SQL> @savedscript Enter the table with chained rows: empchain Table created. old 1: analyze table &chaintabl new 1: analyze table empchain Table analyzed. old 3: from &chaintabl new 3: from empchain Table created. old 1: delete from &chaintabl new 1: delete from empchain 0 rows deleted. old 1: insert into &chaintabl new 1: insert into empchain 0 rows created. Table dropped. * Note that the example table did not have any chained rows. |
|
Disclaimer | |
EXCEPT WHERE EXPRESSLY PROVIDED OTHERWISE, THE INFORMATION, SOFTWARE, PROVIDED ON AN "AS IS" AND "AS AVAILABLE" BASIS. ORACLE EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ORACLE MAKES NO WARRANTY THAT: (A) THE RESULTS THAT MAY BE OBTAINED FROM THE USE OF THE SOFTWARE WILL BE ACCURATE OR RELIABLE; OR (B) THE INFORMATION, OR OTHER MATERIAL OBTAINED WILL MEET YOUR EXPECTATIONS. ANY CONTENT, MATERIALS, INFORMATION OR SOFTWARE DOWNLOADED OR OTHERWISE OBTAINED IS DONE AT YOUR OWN DISCRETION AND RISK. ORACLE SHALL HAVE NO RESPONSIBILITY FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR LOSS OF DATA THAT RESULTS FROM THE DOWNLOAD OF ANY CONTENT, MATERIALS, INFORMATION OR SOFTWARE. ORACLE RESERVES THE RIGHT TO MAKE CHANGES OR UPDATES TO THE SOFTWARE AT ANY TIME WITHOUT NOTICE. |
|
Limitation of Liability | |
IN NO EVENT SHALL ORACLE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES, OR DAMAGES FOR LOSS OF PROFITS, REVENUE, DATA OR USE, INCURRED BY YOU OR ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT, ARISING FROM YOUR ACCESS TO, OR USE OF, THE SOFTWARE. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OR EXCLUSION OF LIABILITY. ACCORDINGLY, SOME OF THE ABOVE LIMITATIONS MAY NOT APPLY TO YOU. |
|
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17252115/viewspace-1136267/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- chained rows analyzeAI
- Listing Chained Rows of Tables and ClustersAI
- Recipe 6.10. Creating a Delimited List from Table RowsMIT
- Script: Script to Simplify the Use of Explain Plan (Doc ID 1019631.6)AI
- SCRIPT: Script to Generate object privilege GRANTS (Doc ID 1020176.6)Object
- 查詢行遷移及消除行遷移(chained rows)AI
- RMAN Backup Shell Script Example (Doc ID 137181.1)
- No Response from the Server, Does it Hang or Spin? (Doc ID 68738.1)Server
- Remove Duplicates from Sorted ListREM
- Script to Show Audit Options/Audit Trail (Doc ID 1019552.6)AI
- Remove-duplicates-from-sorted-listREM
- Remove-duplicates-from-sorted-arrayREM
- Remove Untagged Images From DockerREMDocker
- RMAN Restore Performance from Tape is Very Poor (Doc ID 850988.1)RESTORM
- How to free space from an ASM diskgroup? (Doc ID 1553744.1)ASM
- Script to Collect DRM Information (drmdiag.sql) (Doc ID 1492990.1)ORMSQL
- Script: To list Foreign Key Constraints (Doc ID 1039297.6)AI
- 26. Remove Duplicates from Sorted ArrayREM
- 83. Remove Duplicates from Sorted ListREM
- execute shell script from stored procedure
- Script to Show System and Object Privs for a User (Doc ID 1019508.6)Object
- Script to Report Extents and Contiguous Free Space (Doc ID 162994.1)
- Script: Computing Table Size
- 19. Remove Nth Node From End of ListREM
- Leetcode Remove Duplicates from Sorted ListLeetCodeREM
- leetcode Remove Duplicates from Sorted ArrayLeetCodeREM
- 82. Remove Duplicates from Sorted List IIREM
- Get your Windows product key from a scriptWindows
- [doc]How To Efficiently Drop A Table With Many Extents
- IMPSHOW2SQL - Extracting SQL from an EXPORT file (Doc ID 29765.1)SQLExport
- TECH: Getting a Stack Trace from a CORE file on Unix (Doc ID 1812.1)
- oracle11g_如何模擬產生行連結或行遷移chained_rowsOracleAI
- Leetcode 26 Remove Duplicates from Sorted ArrayLeetCodeREM
- Leetcode Remove Duplicates from Sorted List IILeetCodeREM
- Leetcode Remove Duplicates from Sorted Array IILeetCodeREM
- Leetcode Remove Nth Node From End of ListLeetCodeREM
- Leetcode-Remove Duplicates from Sorted ListLeetCodeREM
- Leetcode-Remove Duplicates from Sorted ArrayLeetCodeREM