[Sqlite], sqlite
I. Install SQLite on Windows
1. Download
Visit the SQLite download page http://www.sqlite.org/download.html to download pre-compiled binary files from windows. You need to download the sqlite-shell-win32-*. zip and sqlite-dll-win32-*. zip unzip installation packages. The two installation packages are as follows:
Http://www.sqlite.org/2014/sqlite-shell-win32-x86-3080600.zip
Http://www.sqlite.org/2014/sqlite-dll-win32-x86-3080600.zip
2. Install
Create the C: \> sqlite folder and decompress the above two compressed files under the folder to obtain the sqlite3.def, sqlite3.dll, and sqlite3.exe files. As follows:
3. Set environment variables:
In Win7:
In the lower left corner, selectStartMenu, on the right of the pop-upComputerSelectAttributeMenu, selectAdvanced System settingsOption, and then selectAdvancedAnd then selectEnvironment variable,InSystem VariablesAdd C: \ sqlite to the end of the par value in the Path column of the option, and clickOKSave and exit, as shown in:
4. Operation demonstration
After the installation, run the sqlite3 command in the cmd.exe command line as follows:
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>,As shown in:
Ii. Install SQLite on Linux
1. Verify that the sqlite version is included.
Currently, SQLite is included in almost all versions of Linux. Therefore, you only need to use the following command to check whether SQLite has been installed on your machine.
[Root @ name01 sqlite-autoconf-3080600] # sqlite3
SQLite version 3.6.20
Enter ". help" for instructions
Enter SQL statements terminated with ";"
Sqlite>
It has been installed, but the sqlite version is not the latest.
2. Install the latest3.8.6Version
For: 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 ~] #
Start Installation
[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
After the installation is complete, check whether the latest version has been updated:
[Root @ name01 sqlite-autoconf-3080600] # sqlite3
SQLite version 3.6.20
Enter ". help" for instructions
Enter SQL statements terminated with ";"
Sqlite>. exit
[Root @ name01 sqlite-autoconf-3080600] #
Update sqlite3 to the latest version.
[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. Now the latest version 3.8.6 Sqlite is used by default in linux.
3. Install SQLite on Mac OS X
PS: I have not installed it on Mac OS X any more. The following is from baidu.
1. Download
The latest version of Mac OS X will pre-install SQLite, but if no installation is available, follow the steps below:
Install the latest version 3.8.6, which is the same as the installation version of sqlite3 in linux.
Address: http://www.sqlite.org/2014/sqlite-autoconf-3080600.tar.gz
Start download and install
$ Wget http://www.sqlite.org/2014/sqlite-autoconf-3080600.tar.gz
2. Install
$ Tar xvfz sqlite-autoconf-3080600.tar.gz
$ Sqlite-autoconf-3080600 cd
$./Configure -- prefix =/usr/local
$ Make
$ Make install
3. log on to sqlite for verification.
The preceding steps install SQLite on Mac OS X. You can run the following command to verify the installation:
$ Sqlite3
SQLite version 3.8.6 2014-08-11 11:46:33
Enter ". help" for usage hints.
Sqlite>
Then you can perform the Sqlite3 operation at the Sqlite3 command prompt.
Sqlite time Method
Datetime ('now ');
Blog.sina.com.cn/s/blog_5fc933730100g25r.html
SQLite statement, understanding, high score
-- When creating a table
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
-- If the table has been created, SQLite does not support renaming columns or modifying the type of columns.
Alter table test to test_temp;
-- Create a new table and add the default value
Create table test (
A integer,
B integer DEFAULT 1,
C integer DEFAULT 2
);
-- Retrieve data from the table
Inset into test (a, B, c)
Select a, B, c from test_temp;