對Oracle Raw類型的詳細(xì)解剖
Jun 07, 2016 pm 03:51 PMSQL create table datatype_test_raw(paddr raw(8)); Table created SQL insert into datatype_test_raw(paddr) values(utl_raw.cast_to_raw('This is a raw type test!')); insert into datatype_test_raw(paddr) values(utl_raw.cast_to_raw('This is a raw
SQL> create table datatype_test_raw(paddr raw(8));Table created
SQL> insert into datatype_test_raw(paddr) values(utl_raw.cast_to_raw('This is a raw type test!'));
insert into datatype_test_raw(paddr) values(utl_raw.cast_to_raw('This is a raw type test!'))
ORA-01401: inserted value too large for column
SQL> alter table datatype_test_raw modify paddr raw(20);
Table altered
SQL> insert into datatype_test_raw(paddr) values(utl_raw.cast_to_raw('This is a raw type test!'));
insert into datatype_test_raw(paddr) values(utl_raw.cast_to_raw('This is a raw type test!'))
ORA-01401: inserted value too large for column
SQL> insert into datatype_test_raw(paddr) values(utl_raw.cast_to_raw('This is a raw test!'));
1 row inserted
SQL> commit;
Commit complete
SQL> select * from datatype_test_raw;
PADDR
----------------------------------------
54686973206973206120726177207465737421
SQL> select utl_raw.cast_to_varchar2(paddr) from datatype_test_raw;
UTL_RAW.CAST_TO_VARCHAR2(PADDR
--------------------------------------------------------------------------------
This is a raw test!
SQL> insert into datatype_test_raw(paddr) values(utl_raw.cast_to_raw('中文測試'));
1 row inserted
SQL> commit;
Commit complete
SQL> select utl_raw.cast_to_varchar2(paddr) from datatype_test_raw;
UTL_RAW.CAST_TO_VARCHAR2(PADDR
--------------------------------------------------------------------------------
This is a raw test!
中文測試
SQL> select paddr, utl_raw.cast_to_varchar2(paddr) from datatype_test_raw;
PADDR UTL_RAW.CAST_TO_VARCHAR2(PADDR
---------------------------------------- --------------------------------------------------------------------------------
54686973206973206120726177207465737421 This is a raw test!
D6D0CEC4B2E2CAD4 中文測試
這里用到了兩個函數(shù):
utl_raw.cast_to_raw([varchar2]);--將varchar2轉(zhuǎn)換為raw類型
utl_raw.cast_to_varchar2([raw]);--將raw轉(zhuǎn)換為varchar2類型
這里varchar2的字符集一般是GB2312。
另外:
utl_raw包的幾個其他的函數(shù)用法:
utl_raw.cast_from_number([number]);
utl_raw.cast_to_number([number]);
位操作:
utl_raw.bit_or();
utl_raw.bit_and();
utl_raw.bit_xor();
另外還有轉(zhuǎn)換函數(shù):
hextoraw(); --將對應(yīng)16進制數(shù)轉(zhuǎn)換為raw
當(dāng)使用HEXTORAW時,會把字符串中數(shù)據(jù)當(dāng)作16進制數(shù)。而使用UTL_RAW.CAST_TO_RAW時,直接把字符串中每個字符的ASCII碼存放到RAW類型的字段中

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

The main difference between MySQL and Oracle is licenses, features, and advantages. 1. License: MySQL provides a GPL license for free use, and Oracle adopts a proprietary license, which is expensive. 2. Function: MySQL has simple functions and is suitable for web applications and small and medium-sized enterprises. Oracle has powerful functions and is suitable for large-scale data and complex businesses. 3. Advantages: MySQL is open source free, suitable for startups, and Oracle is reliable in performance, suitable for large enterprises.

MySQL is popular because of its excellent performance and ease of use and maintenance. 1. Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2. Insert and query data: operate data through INSERTINTO and SELECT statements. 3. Optimize query: Use indexes and EXPLAIN statements to improve performance.

MySQL uses GPL and commercial licenses for small and open source projects; Oracle uses commercial licenses for enterprises that require high performance. MySQL's GPL license is free, and commercial licenses require payment; Oracle license fees are calculated based on processors or users, and the cost is relatively high.

The key to learning Java without taking detours is: 1. Understand core concepts and grammar; 2. Practice more; 3. Understand memory management and garbage collection; 4. Join online communities; 5. Read other people’s code; 6. Understand common libraries and frameworks; 7. Learn to deal with common mistakes; 8. Make a learning plan and proceed step by step. These methods can help you master Java programming efficiently.

The difference and connection between SQL and MySQL are as follows: 1.SQL is a standard language used to manage relational databases, and MySQL is a database management system based on SQL. 2.SQL provides basic CRUD operations, and MySQL adds stored procedures, triggers and other functions on this basis. 3. SQL syntax standardization, MySQL has been improved in some places, such as LIMIT used to limit the number of returned rows. 4. In the usage example, the query syntax of SQL and MySQL is slightly different, and the JOIN and GROUPBY of MySQL are more intuitive. 5. Common errors include syntax errors and performance issues. MySQL's EXPLAIN command can be used for debugging and optimizing queries.

In different application scenarios, choosing MongoDB or Oracle depends on specific needs: 1) If you need to process a large amount of unstructured data and do not have high requirements for data consistency, choose MongoDB; 2) If you need strict data consistency and complex queries, choose Oracle.

Learning Java requires learning basic syntax, object-oriented programming, collection frameworks, exception handling, multithreading, I/O streaming, JDBC, network programming, and advanced features such as reflection and annotation. 1. The basic syntax includes variables, data types, operators and control flow statements. 2. Object-oriented programming covers classes, objects, inheritance, polymorphism, encapsulation and abstraction. 3. The collection framework involves ArrayList, LinkedList, HashSet, and HashMap. 4. Exception handling ensures program robustness through try-catch block. 5. Multithreaded programming requires understanding of thread life cycle and synchronization. 6. I/O streams are used for data reading, writing and file operations. 7. JDBC is used to interact with databases. 8. Network programming passes S

Oracle software can improve performance in a variety of ways. 1) Optimize SQL queries and reduce data transmission; 2) Appropriately manage indexes to balance query speed and maintenance costs; 3) Reasonably configure memory, optimize SGA and PGA; 4) Reduce I/O operations and use appropriate storage devices.
