SQLite Embedded Database Explained

Source: Internet
Author: User
Tags sql error sqlite sqlite database

In a computer system, there are generally two ways to save data:
1. common file Mode
2. Database mode


Using a database to manage large volumes of data is more efficient and more secure than normal file methods.


The database system is generally composed of 3 parts
1. Database
2. Database management System
3. Database Access applications

In the database, the data is stored as a table . There may be an association between the table and the table

SQL (Structured Query language) is a special programming language used to access the data in a database .

1. Create a table
CREATE TABLE TabName (col1 type1 [NOT NULL] [primary key],col2 type2 [Notnull],..)


2. Inserting data into the table
Insert INTO table1 (field1,field2) VALUES (value1,value2)


3. Querying the required data from the table
SELECT * FROM table1 where field1 like '%value1% '


4. Delete data from a table
Delete from table1 where range

SQLite database access application

#include <stdio.h>#include<sqlite3.h>Static intCallbackvoid*notused,intargcChar**ARGV,Char**azcolname) {       inti;  for(i=0; i<argc; i++) {printf ("%s =%s\n", Azcolname[i], argv[i]? Argv[i]:"NULL"); } printf ("\ n"); return 0;} intMainintargcChar**argv) {Sqlite3*DB; Char*zerrmsg =0; intRC; if(argc!=3) {fprintf (stderr,"Usage:%s DATABASE sql-statement\n", argv[0]); }           /*Open Database*/RC= Sqlite3_open (argv[1], &db); if(RC) {fprintf (stderr,"Can ' t Open database:%s\n", sqlite3_errmsg (db));      Sqlite3_close (DB); }           /*Execute SQL Language*/RC= Sqlite3_exec (db, argv[2], Callback,0, &zerrmsg); if(rc!=SQLITE_OK) {fprintf (stderr,"SQL Error:%s\n", zerrmsg); }           /*Close the database*/sqlite3_close (DB); return 0; }

SQLite Embedded Database Explained

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.