Common Oracle operation commands summarized by yourself

Source: Internet
Author: User
IMP username/password file =/home/newbak. DMP full = y imp alpha/123456 file =/home/db20120308.dmp full = ysql> grant create user, drop user, alter user, create any view, drop any view, exp_full_database, imp_full_database, dBA, connect, resource, create session to Alpha; imp alpha/123456 file = D:/DB/sxptccsbjg. DMP full = yoracle data import and export imp/exp function: Oracle Data Import and Export imp/exp is equivalent to Oracle data restoration and backup. In most cases, you can use ORACLE data import and export to back up and restore data (without causing data loss ). Oracle has a benefit. Although your computer is not a server, you have installed an Oracle client and established a connection (add the correct service name through net configuration assistant, in fact, you can think of a path between the client and the server, and then the data can be pulled.) in this way, you can export the data locally, although the server may be far away from you. You can also import the DMP file locally to a database server in a distance. With this function, you can build two identical databases, one for testing and the other for formal use. Execution Environment: In sqlplus. execute in EXE or DoS (command line). When dos can be executed, because the installation directory \ $ ora10g \ bin in Oracle 8i is set to a global path, this directory contains exp. EXE and imp. the EXE file is used for import and export. Oracle is written in Java. I think the sqlplus. EXE, exp. EXE, and imp. EXE files are packaged class files. Sqlplus. EXE calls exp. EXE and imp. EXE to complete the import and export functions. The following describes the Import and Export instances. You can import and export instances to the Import and Export instances, because the import and export operations are very simple. Data export: 1 completely export the database test, and the user name system password manager is exported to D: \ daochu. exp system/manager @ test file = D: \ daochu in DMP. DMP full = Y 2 export the tables of system users and SYS users in the database exp system/manager @ test file = D: \ daochu. DMP owner = (system, sys) 3 Export tables Table1 and Table2 in the database exp system/manager @ test file = D: \ daochu. DMP tables = (Table1, table2) 4. Export the filed1 field in table 1 in the database with the data Header "00" exp system/manager @ test file = D: \ daochu. DMP tables = (Table1) query = \ "where Filed1 like '000000' \ "is commonly used for export. I am not very concerned about compression. You can use WinZip to compress DMP files. However, after the preceding command, compress = y can be used to import data. 1. Import the data in D: \ daochu. dmp to the test database. IMP system/manager @ test file = D: \ daochu. dmp may be faulty because some tables already exist, and an error is reported, so the table will not be imported. Add ignore = Y to the end. 2. Importing table 1 in D: \ daochu. dmp to IMP system/manager @ test file = D: \ daochu. dmp tables = (Table1) is sufficient. In many cases, I completely delete the table and then import it. Note: if you have sufficient permissions, the system will prompt you. Databases can be connected. You can use tnsping test to obtain whether the database test can be connected. Export data: EXP hkb/hkb @ boss_14 full = y file = c: \ orabackup \ hkbfull. DMP log = c: \ orabackup \ hkbfull. log; export Note: The data of the current user is exported. If the current user has DBA permissions, all data is exported! Import data between users with the same name: IMP hkb/hkb @ Xe file = c: \ orabackup \ hkbfull. DMP log = c: \ orabackup \ hkbimp. log full = y data import between different names: IMP system/test @ Xe fromuser = hkb touser = hkb_new file = C: \ orabackup \ hkbfull. dmplog = c: \ orabackup \ hkbimp. log; ORACLE data import and export imp/exp is equivalent to Oracle data restoration and backup. The exp command can export data from the remote database server to the local DMP file, and the IMP command can import the DMP file from the local to the distant database server. This function can be used to build two identical databases, one for testing and the other for formal use. Execution Environment: In sqlplus. execute in EXE or DoS (command line). When dos can be executed, because the installation directory ora81bin in Oracle 8i is set to a global path, there is exp in this directory. EXE and imp. the EXE file is used for import and export. Oracle is written in Java. sqlplus. EXE, exp. EXE, and imp. EXE files may be packaged class files. Sqlplus. EXE calls the classes encapsulated by exp. EXE and imp. EXE to complete the Import and Export function. The following describes the Import and Export instances. Data export: 1 completely export the database test, and the user name system password manager is exported to D: daochu. exp system/manager @ test file = D: daochu in DMP. DMP full = Y 2 export the tables of system users and SYS users in the database exp system/manager @ test file = D: daochu. DMP owner = (system, sys) 3 export the database tables inner_policy and policy_staff_relat to exp aichannel/aichannel @ testdb2 file = D: datanewsmgnt. DMP tables = (inner_policy, policy_staff_relat) 4. Export the filed1 field in table 1 in the database with the data Header "00" exp system/manager @ Test File = D: daochu. DMP tables = (Table1) query = "where filed1 like '000000'" is commonly used for export. For compression, you can use WinZip to compress DMP files. You can also add compress = Y to the command above. Import data 1 import the data in D: daochu. dmp to the test database. IMP system/manager @ test file = D: daochu. DMP imp aichannel/aichannel @ HUST full = y file = D: datanewsmgnt. DMP ignore = y may be faulty because some tables already exist and an error is reported. Add ignore = Y to the end. 2. Importing table 1 in D: daochu. dmp to IMP system/manager @ test file = D: daochu. dmp tables = (Table1) is sufficient. In many cases, you must first completely delete the table and then import it. Note: If the operator has sufficient permissions, a prompt is displayed. Databases can be connected. You can use tnsping test to obtain whether the database test can be connected. Appendix 1: add data import permissions to users first, start SQL * puls second, log on to system/manager third, create user username identified by password (if you have already created a user, this step can be omitted) 4. Grant create user, drop user, alter user, create any view, drop any view, exp_full_database, imp_full_database, DBA, connect, resource, create session to username 5th, run-cmd-Enter the directory where the DMP file is located, IMP userid = system/manager full = y file = *. DMP or imp userid = system/manager full = y file = filename. DMP execution example: F: Work Oracle_databackup> imp userid = test/test full = y file = inner_policy.dmp screen display import: Release 8.1.7.0.0-production on Thursday February 16 16:50:05 2006 (c) Copyright 2000 Oracle Corporation. all rights reserved. connect to: Oracle8i Enterprise Edition Release 8.1.7.0.0-productionwith the partitioning optionjserver release 8.1.7.0.0-Production Export by export: the file created in v08.01.07 has completed the import and export of the zhs16gbk Character Set and zhs16gbk nchar character set by the server u Tf8 nchar character set (possible ncharset conversion ). importing aichannel object to aichannel .. importing table "inner_policy" 4 rows are being imported to prepare to enable constraints... import is terminated successfully, but a warning is displayed. Appendix 2: Oracle does not allow direct change of the table owner. Export/Import can be used for this purpose. create import9.par first. Then, run the following command to use import9.par: IMP parfile =/filepath/import9.par. The content of import9.par is as follows: fromuser = tgpms touser = tgpms2 (note: change the table owner from fromuser to touser. Users of fromuser and touser can be different) rows = y indexes = y grants = y constraints = y buffer = 409600 file =/backup/ctgpc_20030623.dmp log =/backup/import_20030623.log

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.