SQLite Data Type

Source: Internet
Author: User

Generally, the static data type is fixed, while SQLite uses the dynamic data type, which is automatically determined based on the stored value. SQLite has the following five types
 
Data Type:
 
1. NULL: NULL.
2. INTEGER: A signed INTEGER, depending on the size of the number to be saved.
3. REAL: floating point number, which is stored as an 8-byte IEEE floating point number.
4. TEXT: String TEXT.
5. BLOB: binary object.
 
 
But in fact, sqlite3 also accepts the following data types:
Smallint is an integer of 16 bits.
An integer of 32-bit interger.
Decimal (p, s) p exact value and the decimal integer of s size. Exact value p refers to the number of digits after the decimal point.
 
If not specified, the system is set to p = 5; s = 0.
Float 32-bit real number.
The real number of the double 64-bit element.
Char (n) n length string, n cannot exceed 254.
A string with an unfixed varchar (n) length and a maximum length of n. n cannot exceed 4000.
Graphic (n) is the same as char (n), but it is measured in double-bytes. n cannot exceed 127. This form supports two characters long.
 
Level font, such as Chinese text.
A dual-character string with a variable vargraphic (n) length and a maximum length of n. n cannot exceed 2000
Date contains the year, month, and date.
Time contains hours, minutes, and seconds.
Timestamp includes year, month, day, hour, minute, second, And 1‰ seconds.
Datetime contains the date and time format. It must be written as '2017-08-05 'and cannot be written as '2017-8-5'. Otherwise, an error will occur during reading!
 
Common Sqlite Data Types
This statement is problematic because SQLite is non-typed. This means that you can save any type of data to any column in any table you want to save.
 
No matter what data type this column declares (only auto-incrementing Integer Primary Key is useful ).
 
All valid. For example:
 
Create Table ex3 (a, B, c );
 
We recommend that you specify the data type in your Create Table statement even if SQLite allows data types to be ignored.
 
It is very useful for programmers to communicate with each other or to change your database engine. SQLite supports common data types, such:
 
SQL code
Create table my_table (
Id integer primary key autoincrement,
A VARCHAR (10 ),
B NVARCHAR (15 ),
C TEXT,
D INTEGER,
E FLOAT,
F BOOLEAN,
G CLOB,
H BLOB,
I NUMERIC,
J DECIMAL (4, 2 ),
K TIMESTAMP,
L DATETIME
);
 
# Database Operations
View Current Database
Sqlite>. databases
View the current database table
Sqlite>. table
View data table structure
Sqlite>. schema school
Modify Table Structure
Sqlite cannot directly Delete fields. You can add fields.
Sqlite> alter table s_class add column bDo int default 0;
To delete a field, you must run SQL statements everywhere and then import data (similar to mysql)
Delete A data table
Sqlite> drop table s_class;

Author "program life"
 

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.