SQLite是關聯式數据庫管理系統。它嵌入到程序中。
數据類型
INTEGER | 64位元整數 |
REAL | 64位元浮點數 |
TEXT | 變長字符串 (UTF-8/16) |
BLOB | 變長二進數据 |
SQL範例程式
SELECT 'Hello,' || 'world';
SELECT "IN" FROM "WHERE";
REPLACE INTO page (title,contents) VALUES(?,?);
C語言範例程式
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
int main(int argc,char **argv)
{
sqlite3 *db;
if (sqlite3_open("test.db", &db) != SQLITE_OK){
fprintf(stderr, "cannot open test.db\n");
exit(1);
}
sqlite3_stmt *st;
if (sqlite3_prepare_v2(db, "SELECT name FROM book WHERE price>?", -1, &st, NULL) != SQLITE_OK) {
fprintf(stderr, "%s\n", sqlite3_errmsg(db));
exit(1);
}
sqlite3_bind_int(st, 0, 100);
while (sqlite3_step(st) == SQLITE_ROW) {
printf("%s\n", sqlite3_column_text(st, 0));
}
sqlite3_finalize(st);
sqlite3_close(db);
return 0;
}