12.30sqlite determines whether a table or field exists. 12.30sqlite Field

Source: Internet
Author: User

12.30sqlite determines whether a table or field exists. 12.30sqlite Field

1. Check whether the table name exists:

Select * from sqlite_master


The sqlite_master table structure is as follows:

Type | name | tbl_name | rootpage | SQL

Demonstrate query results;

==================
Type> table
Name> android_metadata
Tbl_name> android_metadata
Rootpage> 3
SQL> CREATE TABLE android_metadata (locale TEXT)
==================
Type> table
Name> TalkVO
Tbl_name> TalkVO
Rootpage> 4
SQL> CREATE TABLE TalkVO (content text, videoPath text, img text, name text, issend BLOB, isPlaying integer, uid integer, _ id integer PRIMARY KEY)

2. Determine whether a field exists

PRAGMA table_info ([TalkVO])

It must be capitalized and the structure is as follows:

Cid | name | type | notnull | dflt_value | pk

Demonstrate query results;

PRAGMA table_info ([TalkVO])
==================
Cid> 0
Name> content
Type> text
Notnull> 0
Dflt_value> null
Pk> 0
==================
Cid> 1
1 name> videoPath
Type> text
Notnull> 0
Dflt_value> null
Pk> 0
==================
Cid> 2
Name> img
Type> text
Notnull> 0
Dflt_value> null
Pk> 0
==================
Cid> 3
Name> name
Type> text
Notnull> 0
Dflt_value> null
Pk> 0
==================
Cid> 4
Name> issend
Type> BLOB
Notnull> 0
Dflt_value> null
Pk> 0
==================
Cid> 5
Name> isPlaying
Type> integer
Notnull> 0
Dflt_value> null
Pk> 0
==================
Cid> 6
Name> uid
Type> integer
Notnull> 0
Dflt_value> null
Pk> 0
==================
Cid> 7
Name >>_id
Type> integer
Notnull> 0
Dflt_value> null
Pk> 1



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.