Oracle create user, tablespace, import and export, ... commands

Oracle create user, tablespace, import and export, ... commands

 
//Create
temporary tablespace create temporary tablespace test_temp
tempfile 'E:\oracle\product\10.2.0\oradata\testserver\test_temp01.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
//Create data tablespace
create tablespace test_data
logging
datafile 'E:\oracle\product\10.2.0\oradata\testserver\test_data01.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
//Create user and specify tablespace
create user testserver_user identified by testserver_user
default tablespace test_data
temporary tablespace test_temp;
//Grant permissions to users
grant connect, resource to testserver_user; (db2: specify all permissions)
Import and export commands:
Oracle data import and export imp/exp is equivalent to oracle data restore and backup. The exp command can export the 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 remote database server. Using this feature, you can build two identical databases, one for testing and one for formal use.

Execution environment: It can be executed in SQLPLUS.EXE or DOS (command line).
When it can be executed in DOS, because the installation directory ora81BIN in oracle 8i is set as the global path,
there are EXP.EXE and IMP.EXE files in this directory. to perform import and export.
Oracle is written in java, and these two files, SQLPLUS.EXE, EXP.EXE, and IMP.EXE, may be packaged class files.
SQLPLUS.EXE calls the classes wrapped by EXP.EXE and IMP.EXE to complete the import and export functions.

The following is an example of import and export.
Data export:
1. Completely export the database TEST, export the user name system password manager to D:daochu.dmp
exp system/manager@TEST file=d:daochu.dmp full=y
2 Export the table of system user and sys user in the database export
exp system/manager@TEST file=d:daochu.dmp owner=(system,sys)
3 Export the tables inner_notify and notify_staff_relat in the database to
exp aichannel/aichannel@TESTDB2 file= d:datanewsmgnt.dmp tables=(inner_notify,notify_staff_relat)
4 Export the tables in the database The field filed1 in table1 is exported with data starting with "00"
exp system/manager@TEST file=d:daochu.dmp tables=(table1) query=" where filed1 like '00%'" The

above is a commonly used export, for compression , both dmp files can be well compressed with winzip.
It can also be achieved by adding compress=y after the above command.
Import
of data 1 Import the data in D:daochu.dmp into the TEST database.
imp system/manager@TEST file=d:daochu.dmp
imp aichannel/aichannel@HUST full=y file=d:datanewsmgnt.dmp ignore=y
There may be a problem with the above, because some tables already exist, and then it will report an error, and the table will not be imported.
Just add ignore=y after it.
2 Import the table table1 in d:daochu.dmp into
imp system/manager@TEST file=d:daochu.dmp tables=(table1)

Basically the above import and export is enough. In many cases, the table must be completely deleted first, and then imported.

Note:
The operator must have enough authority, if the authority is not enough, it will prompt.
can be connected to the database. You can use tnsping TEST to get whether the database TEST can be connected.
Appendix 1:
Operation of adding data import permissions to users
First , start sql*puls
Second, log in with system/manager
Third , create user username IDENTIFIED BY password (if a user has already been created, this step can be omitted)
Fourth , 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 user name
Fifth , run -cmd- to 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:WorkOracle_Databackup>imp userid=test/test full=y file=inner_notify.dmp
The screen shows
Import: Release 8.1.7.0.0 - Production on Thu Feb 16 16:50:05 2006
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Link to: Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
With the Partitioning option
JServer Release 8.1.7.0.0 - Production
exports files created by EXPORT:V08.01.07 via regular path
Imports done in ZHS16GBK charset and ZHS16GBK NCHAR charset
Export server uses UTF8 NCHAR charset (possible ncharset conversion)
. Importing AICHANNEL objects into AICHANNEL
.. Importing table "INNER_NOTIFY" 4 rows are imported
Ready to enable constraints...
Import successfully terminated with warnings.

Appendix 2:
Oracle does not allow to directly change the owner of the table. This can be achieved by using Export/Import.
First create import9.par,
and then use the following command: imp parfile=/filepath/import9.par
Example import9.par content As follows:
FROMUSER=TGPMS
TOUSER=TGPMS2 (Note: Change the owner of the table from FROMUSER to TOUSER, the 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

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326987958&siteId=291194637