Oracle 9i Optimization of char Field Types

Source: Internet
Author: User

In Oracle 9i, reading char fields is inconvenient, which limits the use of char fields. to read the value of a field, use the following methods:

 

SQL> Create Table Test (

2 a char (5 ))

3 tablespace users;

 

The table has been created.

 

SQL> insert into test values ('1 ');

 

One row has been created.

 

SQL> insert into test values ('2 ');

 

One row has been created.

 

SQL> insert into test values ('20140901 ');

 

One row has been created.

 

SQL> select * from test;

 

A

-----

1

2

12345

SQL> select * from test where trim (A) = '1 ';

 

A

-----

1

SQL> select * from test where a = '1 ';

 

A

-----

1

Before reading data, you must first remove spaces or consider spaces.

 

In Oracle 9i, the char field is optimized and can be read using the following methods:

SQL> select * from test where a = '1 ';

 

A

-----

1

This reading method is the same as reading a varhcar field. Therefore, when reading a field string, you do not need to consider the char or varchar type, at the same time, due to the efficiency advantage of char fields, char fields can be used for character fields with little length changes.

Finally:

SQL> truncate table test;

The table has been truncated.

SQL> drop table test;

The table is discarded.

SQL>

 

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.