[Sqlite],sqlite

來源:互聯網
上載者:User

[Sqlite],sqlite
一:在 Windows 上安裝 SQLite

 1,下載

請訪問SQLite下載頁面http://www.sqlite.org/download.html,從Windows 區下載先行編譯的二進位檔案。需要下載 sqlite-shell-win32-*.zip 和 sqlite-dll-win32-*.zip 壓縮檔,這裡下載sqlite-dll-win32-x86-3080600.zip和sqlite-shell-win32-x86-3080600.zip安裝包。2個安裝包如下:

http://www.sqlite.org/2014/sqlite-shell-win32-x86-3080600.zip

http://www.sqlite.org/2014/sqlite-dll-win32-x86-3080600.zip


 
2,安裝

建立檔案夾 C:\>sqlite,並在此檔案夾下解壓上面兩個壓縮檔,將得到 sqlite3.def、sqlite3.dll 和 sqlite3.exe 檔案。如下所示:

 

3,設定環境變數:

Win7系統下面:

左下角,選擇開始菜單,在彈出的右邊電腦選項上面單機右鍵,選擇屬性菜單,選擇進階系統設定選項,再選擇進階,再選擇環境變數,系統變數選項裡面的Path欄裡面值的最末尾添加上C:\sqlite,點擊確定按鈕儲存退出,如所示:


4,操作示範驗證

添加完後,在cmd.exe命令列裡使用sqlite3命令操作如下:

C:\Users\Administrator>sqlite3 ti

SQLite version 3.8.6 2014-08-15 11:46:33

Enter ".help" for usage hints.

sqlite> create table t1(id int);

sqlite> insert into t1 select 1;

sqlite> .headers on

sqlite> .mode columns

sqlite> select * from t1;

id

----------

1

sqlite>

sqlite>

sqlite> .exit

 

C:\Users\Administrator>,如所示:



二:在 Linux 上安裝 SQLite


1,驗證是否已經內建sqlite版本
目前,幾乎所有版本的 Linux 作業系統都附帶 SQLite。所以,只要使用下面的命令來檢查您的機器上是否已經安裝了 SQLite。

[root@name01 sqlite-autoconf-3080600]# sqlite3

SQLite version 3.6.20

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite>
已經安裝了,不過sqlite版本不是最新的。

 

2,去安裝最新的3.8.6版本

為:http://www.sqlite.org/2014/sqlite-autoconf-3080600.tar.gz

 

[root@name01 ~]# wget http://www.sqlite.org/2014/sqlite-autoconf-3080600.tar.gz

[root@name01 ~]#

開始安裝

[root@name01 ~]# tar -xvf sqlite-autoconf-3080600.tar.gz

[root@name01 ~]# cd sqlite-autoconf-3080600

[root@name01 sqlite-autoconf-3080600]# ./configure --prefix=/usr/local

[root@name01 sqlite-autoconf-3080600]# make

[root@name01 sqlite-autoconf-3080600]# make install

安裝完畢,查看是否已經更新最新版本:

[root@name01 sqlite-autoconf-3080600]# sqlite3

SQLite version 3.6.20

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite> .exit

[root@name01 sqlite-autoconf-3080600]#

手動將sqlite3更新成最新版本

[root@name01 sqlite-autoconf-3080600]# cp /usr/bin/sqlite3 /usr/bin/sqlite3.bak.3.6.2

[root@name01 sqlite-autoconf-3080600]# cp sqlite3 /usr/bin/sqlite3

cp: overwrite `/usr/bin/sqlite3'? y

[root@name01 sqlite-autoconf-3080600]# sqlite3 ti

SQLite version 3.8.6 2014-08-15 11:46:33

Enter ".help" for usage hints.

sqlite>

sqlite> .table

sqlite>

OK,linux上面現在預設的已經是最新的3.8.6版本的Sqlite了。 


三:在 Mac OS X 上安裝 SQLite

PS:沒有再Mac OS X上安裝過,以下是baidu出來的,可以借鑒一下。

1,下載
最新版本的 Mac OS X 會預先安裝 SQLite,但是如果沒有可用的安裝,只需按照如下步驟進行:

去安裝最新的3.8.6版本,和linux的sqlite3安裝版本是同一個。

軟體地址為:http://www.sqlite.org/2014/sqlite-autoconf-3080600.tar.gz

開始下載安裝

$ wget http://www.sqlite.org/2014/sqlite-autoconf-3080600.tar.gz

2,安裝

$tar xvfz sqlite-autoconf-3080600.tar.gz

$cd sqlite-autoconf-3080600

$./configure --prefix=/usr/local

$make

$make install

 
3,登入sqlite驗證

上述步驟將在 Mac OS X 機器上安裝 SQLite,您可以使用下列命令進行驗證:

$sqlite3

SQLite version 3.8.6 2014-08-11 11:46:33

Enter ".help" for usage hints.

sqlite>

之後就可以在Sqlite3命令提示字元下,進行Sqlite3操作。


sqlite 時間 方法

datetime('now');
blog.sina.com.cn/s/blog_5fc933730100g25r.html
 
SQLite語句,懂得進,高分

-- 建立表時
create table test(
a integer,
b integer DEFAULT 1,
c integer
);

insert into test (a) values(12);

select * from test;
a b c
-------------------
12 1

-- 如果表已經建立 那麼,由於SQLite不支援對列的改名和修改類型等操作,那麼需要這樣修改。
alter table test to test_temp;
-- 重新建立表,增加預設值

create table test(
a integer,
b integer DEFAULT 1,
c integer DEFAULT 2
);
-- 將表中資料拿回來

inset into test (a, b, c)
select a, b, c from test_temp;
 

相關文章

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.