The statement for creating a user with Complete Oracle Database User management and data import and export is as follows:
CREATE USER
IDENTIFIED BY
DEFAULT TABLESPACE
TEMPORARY TABLESPACE
;
|
Take creating a katrina user as an example:
SQL> CREATE USER katrina IDENTIFIED BY iloveyou 2 DEFAULT TABLESPACE users 3 TEMPORARY TABLESPACE temp; User created. |
Syntax for changing the default data table space:
alter database default tablespace
;
|
Syntax for changing the default temporary tablespace:
alter database default temporary tablespace
;
|
Grant permissions to users
grant connect,resource to testserver_user; |
// Log on to the user later. Any database objects created belong to the test_temp and test_data tablespaces. Therefore, you do not need to specify a tablespace for each object created.
Unlock users and log on with system
alert user scott account unlock; |
Tablespaces are containers of data files. In windows, because windows does not have a raw device concept, tablespaces become dispensable. However, in unix systems, tablespaces act as file systems, it enables oracle to skip the operating system and directly manage physical storage devices. This greatly improves system performance, reduces fragmentation, and reduces I/o call layers) generally, a large user uses a tablespace, and a few small users can share a tablespace.
Generally, not all users share a large tablespace, because it is not convenient for Oracle management. 1. Easy to manage
2. Prevent data loss
You can create many data files in a tablespace and place the data files in the tablespace on different disks. If the D disk is broken, the data on the d disk is lost, no data files are lost in the tablespace I placed in drive F.
3. Placing the data files in the tablespace on different disks can improve the disk read and write efficiency. Oracle creates users, tablespaces, imports and exports,... commands
// Create a temporary tablespace Create temporary tablespace test_temp Tempfile 'e: \ oracle \ product \ 10.2.0 \ oradata \ testserver \ test_temp01.dbf' Size 32 m Autoextend on Next 32 m maxsize 2048 m Extent management local; // Create a data table space Create tablespace test_data Logging Datafile 'e: \ oracle \ product \ 10.2.0 \ oradata \ testserver \ test_data01.dbf' Size 32 m Autoextend on Next 32 m maxsize 2048 m Extent management local; // Create a user and specify the 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)
|
Data Import and Export commands:
Importing and exporting Oracle Data imp/exp is equivalent to restoring and backing up oracle data. 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 doscommand 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. Export the database TEST completely, and the username system Password manager is exported to D: daochu. dmp.
Exp system/manager @ TEST file = d: daochu. 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 inner_policy and policy_staff_relat tables in the database.
Exp aichannel/aichannel @ TESTDB2 file = d: datanewsmgnt. dmp tables = (inner_policy, policy_staff_relat)
4. Export the data with the field filed1 in table 1 in the database starting with "00"
Exp system/manager @ TEST file = d: daochu. dmp tables = (table1) query = "where filed1 like '201312 '"
The above is a commonly used export. For compression, you can use winzip to compress the dmp file.
You can also add compress = y to the command above.
Data Import
1. import data from 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
|
The above may be a problem, because some tables already exist, and then it will report an error, the table will not be imported.
Add ignore = y to the end.
2. Import table 1 in d: daochu. dmp
Imp system/manager @ TEST file = d: daochu. dmp tables = (table1)
The preceding import and export operations are 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 in with system/manager
Third, create user username identified by password. If you have already created a user, skip this step)
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 Username
|
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
Example:
F: WorkOracle_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-Production
With the Partitioning option
JServer Release 8.1.7.0.0-Production
The file created by EXPORT: V08.01.07 has been exported through the conventional path. The Import and EXPORT server in the ZHS16GBK Character Set and ZHS16GBK NCHAR Character Set uses the UTF8 NCHAR character set (possible ncharset conversion)
. Importing AICHANNEL object to AICHANNEL
.. Importing table "inner_policy" 4 rows
Prepare to enable constraints...
Import is terminated successfully, but a warning is displayed.
Appendix 2:
Oracle cannot directly change the table owner. Export/Import can be used to achieve this purpose.
First create import9.par,
The command is as follows: 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 |
- Oracle performance optimization achieved through Partitioning technology
- A simple view on Oracle concurrent processing mechanism
- Solution to Oracle locking
- Three methods to simplify the management of Oracle table columns
- Differences between Query rownum and rowid in Oracle