日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

QT中Sqlite的使用

發(fā)布時間:2025/3/21 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 QT中Sqlite的使用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

環(huán)境:

靜態(tài)編譯過sqlite

?

步驟:

1.C++鏈接器中加入Sqlite.lib,然后在測試一下是否能正常加載Sqlite驅(qū)動

#include<QtPlugin>

Q_IMPORT_PLUGIN(sqlite)

測試打印:

QStringList dirvers = QSqlDatabase:drivers();

qDebug() << drivers;

?

?

2.能正常加載的情況下,繼續(xù)如下,不能的話檢查庫路徑知否加載正確。

下一個sqlite.exe,其中命令為:

sqlite SQL語句


>dos下啟動sqlite
sqlite3.ext test.db
#查看數(shù)據(jù)庫
.databases
>dos下執(zhí)行sql命令
sqlite3.exe test.db < test.sql
>dos下dump命令
sqlite3.exe test.db .dump > test.sql
>加載數(shù)據(jù)庫
attach database 'test.db' as test;
>卸載數(shù)據(jù)庫
detach database test;
>創(chuàng)建表
create table test(id integer primary key, name text);
>創(chuàng)建視圖
create view testview as select * from test;
>創(chuàng)建索引
create index idx_name on test(name);
>重建索引
reindex test;
或者
reindex idx_name;
>添加數(shù)據(jù)
insert into test(name) values('123');
select last_insert_rowid();
>查詢數(shù)據(jù)
select * from test;
>系統(tǒng)表
select * from sqlite_master;
>sqlite支持ANSI SQL中除right outer join和full outer join之外的所有操作
>sqlite支持limit子句
>sqlite的表默認生成自增長的64位整型字段rowid,別名oid

?

?

?

下面為測試用例:

SQLIte中,主鍵Integer PRIMARY KEY是默認自增的。

OK,后面自己去寫代碼實現(xiàn)數(shù)據(jù)庫連接把

轉(zhuǎn)載于:https://www.cnblogs.com/hermit/p/3552311.html

總結(jié)

以上是生活随笔為你收集整理的QT中Sqlite的使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。