SQL and Oracle and Mysql Data Types

Source: Internet
Author: User

Structured Query Language (Structured Query Language), also known as structured query language, is a standard language for defining and querying and manipulating data in relational databases. It is an interface for communication between users and databases, almost all databases such as Oracle, MySQL, and SQL server support SQL queries. The SQL language has a simple structure, powerful functions, and is easy to learn. Therefore, since its launch, the SQL language has been widely used.

The SQL language consists of the following five sub-languages:

DDL-Data Definition Language );

Data Query Language (selete-query statements );

DML-datat manipulation language );

Transaction Control Language (TC-transaction control statements );

Data Control Language (DCL-datat control language );


Data Type

Oracle and MySQL are two important types of data. The following describes their basic data types.

Data Type

Data Type

Description

Oracle

MySQL

Value Type

Number (P, S)

Stores numeric data types, such as floating point, integer, score, and dual-precision. Where p is the precision, indicating the total number of digits (1 <= P <= 38); s is the range, indicating the number of digits on the right of the decimal point, which is between-84 and 127. The default value is 38 characters.

Tinyint

Tiny integer, 1 byte

Smallint

Small integer, 2 bytes

Mediumint

Medium integer, 3 bytes

Int or integer

Integer Data Type

Integer, 4 bytes

Bigint

Big integer, 8 bytes

Float

Floating Point Data Type

Single-precision floating point value, 4 bytes

Double

Double-precision floating point value, 8 bytes

Decimal

For decimal (M, d), if M> D is m + 2, otherwise d + 2

String type

Char (N)

N = 1to2000 bytes, fixed length string, n Bytes long. If no length is specified, the default value is 1 byte long (one Chinese character is 2 bytes)

Fixed-length string, 0-bytes

Nchar (N)

NLS (National Language Support, international language support) data types can only store UNICODE character sets defined by the database NLS character set. Oracle can store up to 2000 bytes

Varchar (N)

A maximum of B can be stored in a variable length. Therefore, no space is required to fill in.

Variable-length string, 0-255 bytes

Nvarchar (N)

N = 1to4000 bytes. A maximum of B bytes can be stored in a variable length. Therefore, no space is required for Supplement.

NLS (National Language Support, international language support) data types can only store UNICODE character sets defined by the database NLS character set.

Varchar2 (N)

Varchar2 is more suitable for use than varchar. Due to compatibility, varchar remains in the Oracle database.

Nvarchar2

The data type of NLS is equivalent to that of varchar2. This data type can be stored at most B.

Clob

Stores a large amount of single-byte character data and multi-byte character data. The maximum storage capacity is 4 GB.

Nclob

It stores variable-length Unicode Character Set character data with a maximum storage capacity of 4 GB.

Blob

Stores large binary objects. Example: graphics, video, audio, etc.

Bfile

Bfile: Specifies the file locator. It points to a binary file located in the file system of the server (storing a file path)

Long

Storage of variable-length character data, up to 2 GB.

Raw

Stores byte-based data. A maximum of 2000 bytes can be stored. The size must be specified. Raw data can be indexed.

Long raw

Stores binary data of variable length. The maximum storage capacity is 2 GB. Cannot be indexed.

Tinyblob

A binary string of no more than 255 characters, ranging from 0 to bytes.

Tinytext

Short text string, 0-255 bytes

Blob

Long text data in binary format, 0-65 535 bytes

Text

Long text data, 0-65 535 bytes

Mediumblob

Moderate-length text data in binary format

Mediumtext

Medium-length text data, 0-16 777 215 bytes

Logngblob

Extremely large text data in binary format, 0-4 294 967 295 bytes

Longtext

Large text data, 0-4 294 967 295 bytes

Date and Time

Date

The date and time data of the table are stored in seven bytes. Each byte is stored in Century, year, month, day, hour, minute, and second. The value ranges from January 1, 4712 BC to December 31, 9999 AD. The sysdate function in Oracle returns the current date and time.

Date, YYYY-MM-DD

Timestamp

The hour, minute, and second values of the year, month, day, and time of the storage date. The second value is accurate to the last six digits of the decimal point and contains the time zone information. The imestamp function in Oracle returns the current date, time, and time zone.

Time

Time Value or duration, HH: mm: SS

Year

Year Value, yyyy

Datetime

Mixed date and time, YYYY-MM-DD hh: mm: SS

Timestamp

Mixed Date and Time Value, timestamp, yyyymmdd hhmmss

Composite Type

Enum

An Enum type can contain a maximum of 65536 elements, one of which is retained by MySQL and used to store error information. This error value is represented by index 0 or an empty string.

Set

Container type. A set type can contain up to 64 elements and cannot contain two identical elements.

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.