IMP同库Type对象导入报错ORA-02304
Type是我们经常使用的数据库对象结构。我们在实际中,可以单独定义type类型,之后在PL/SQL代码或者数据表中使用。 在一个偶然的机
Type是我们经常使用的数据库对象结构。我们在实际中,可以单独定义type类型,之后在PL/SQL代码或者数据表中使用。
在一个偶然的机会让笔者发现使用Type类型在数据exp/imp中的麻烦。当我们使用exp/imp工具进行同数据库实例(Instance)不同Schema之间数据拷贝时,如果Schema中有type类型,就会出现问题错误。
具体我们还是通过一系列的实验进行证明。
1、实验环境准备
我们使用10gR2作为实验数据库。
SQL> conn scott/tiger@ots;
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as scott
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
我们首先将scott用户schema的所有对象导出。注意,当前scott下存在一些数据type对象。
SQL> select type_name, type_oid, typecode from user_types;
TYPE_NAME TYPE_OID TYPECODE
------------------------------ -------------------------------- ------------------------------
CUST_ADDRESS_TYPE_NEW 0239FC5ABD78464D8D6C4D7085E2F549 OBJECT
T_REC_TEST 428A1B3C7E1E4A3CB2063B93623693EA OBJECT
T_REC_TABLE D9AFD3FAE0A54964B1684CA28C69CEED COLLECTION
T_TYP 8E294AB7CC28493A94FF82791A376379 OBJECT
N_TYP 338172B836854BAB8C26D4C27B5908F1 OBJECT
在Oracle中,每一个type都会分配出唯一的oid编号,作为一种内部标志。下面,我们使用exp工具将scott用户对象导出。
D:\>exp scott/tiger@ots file=scott_20120606.dmp indexes=y rows=y compress=y cons
traints=y wner=scott
Export: Release 10.2.0.1.0 - Production on星期三6月6 17:22:16 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已导出ZHS16GBK字符集和AL16UTF16 NCHAR字符集
即将导出指定的用户...
.正在导出pre-schema过程对象和操作
.正在导出用户SCOTT的外部函数库名
.导出PUBLIC类型同义词
.正在导出专用类型同义词
.正在导出用户SCOTT的对象类型定义
(篇幅原因,部分省略……)
成功终止导出,没有出现警告。
D:\>
之后,我们创建同数据库用户scottback。
SQL> create user scottback identified by scottback;
User created
SQL> grant resource to scottback;
Grant succeeded
SQL> grant connect to scottback;
Grant succeeded
SQL> grant exp_full_database to scottback;
Grant succeeded
SQL> grant imp_full_database to scottback;
Grant succeeded
2、数据导入
当我们试图将数据导入到相同数据库时,出现报错。
D:\>imp scottback/scottback@ots file=scott_20120606.dmp indexes=y rows=y constra
ints=y ignore=y fromuser=scott touser=scottback
Import: Release 10.2.0.1.0 - Production on星期三6月6 17:34:21 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
经由常规路径由EXPORT:V10.02.01创建的导出文件
警告:这些对象由SCOTT导出,而不是当前用户
已经完成ZHS16GBK字符集和AL16UTF16 NCHAR字符集中的导入
IMP-00017:由于ORACLE错误2304,以下语句失败:
"CREATE TYPE "T_REC_TEST" TIMESTAMP '2010-12-21:18:17:30' OID '428A1B3C7E1E4"
"A3CB2063B93623693EA' as object("
"id number);"
""
""
IMP-00003:遇到ORACLE错误2304
ORA-02304:无效的对象标识符文字
IMP-00017:由于ORACLE错误2304,以下语句失败:
"CREATE TYPE "T_REC_TABLE" TIMESTAMP '2010-12-21:18:17:33' OID 'D9AFD3FAE0A5"
"4964B1684CA28C69CEED' as table of t_rec_test;"
""
""
IMP-00003:遇到ORACLE错误2304
ORA-02304:无效的对象标识符文字
IMP-00017:由于ORACLE错误2304,以下语句失败:
"CREATE TYPE "T_TYP" TIMESTAMP '2012-03-07:10:47:03' OID '8E294AB7CC28493A94"
"FF82791A376379' as object (id number);"
""
""
IMP-00003:遇到ORACLE错误2304
ORA-02304:无效的对象标识符文字
IMP-00017:由于ORACLE错误2304,以下语句失败:
"CREATE TYPE "N_TYP" TIMESTAMP '2012-03-07:11:03:01' OID '338172B836854BAB8C"
"26D4C27B5908F1' as object (t_id number,t_name varchar2(10),t_addr varchar"
"2(20));"
""
""
IMP-00003:遇到ORACLE错误2304
ORA-02304:无效的对象标识符文字
IMP-00017:由于ORACLE错误2304,以下语句失败:
"CREATE TYPE "CUST_ADDRESS_TYPE_NEW" TIMESTAMP '2012-05-23:16:15:03' OID '02"
"39FC5ABD78464D8D6C4D7085E2F549' as object"
"(street_address varchar2"
"(40),"
"postal_code varchar2(10)"
",city varchar2(30)"
",state_province varchar2(10)"
",country_id char(2)"
");"
""
""
IMP-00003:遇到ORACLE错误2304
ORA-02304:无效的对象标识符文字
(篇幅原因,部分省略…..)
ORA-02270:此列列表的唯一或主键不匹配
即将启用约束条件...
成功终止导入,但出现警告。
从日志信息上,,我们看到在创建type类型变量的时候,Oracle报错2304。利用oerr工具,我们可以检查错误信息。
[oracle@bspdev ~]$ oerr ora 2304
02304, 00000, "invalid object identifier literal"
// *Cause: An attempt was made to enter an object identifier literal for
// CREATE TYPE that is either:
// - not a string of 32 hexadecimal characters
// - an object identifier that already identifies an existing
// object
// - an object identifier different from the original object
// identifier already assigned to the type
// *Action: Do not specify the object identifier clause or specify a 32
// hexadecimal-character object identifier literal that is unique
// or identical to the originally assigned object identifier. Then
// retry the operation.
从字面的情况看,是创建type的命令语句出现错误。从脚本的信息上,的确显示的script中创建type的语句是很特殊,中间有timestamp和oid信息。而且与原来schema中的相对应。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values and pointers to data rows, and is suitable for non-primary key column queries.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.
