Shallow with Sqlite3 (i.)

Source: Internet
Author: User
Tags echo command sqlite sqlite database

Recently work contact to Sqlite3, so with blog record, of course only shallow use ha!

Reference:http://www.runoob.com/sqlite/sqlite-tutorial.html

Concept:

SQLite is a software library that implements a self-contained, server-free, 0-configured, transactional SQL database engine. It is a 0 configured database, which means that, like other databases, you do not need to be configured in the system.

Just like other databases, the SQLite engine is not a standalone process that can be statically or dynamically connected by application requirements. SQLite accesses its storage files directly.

SQLite is the most widely deployed SQL database engine in the world. SQLite source code is not subject to copyright restrictions.

Advantage:

    • There is no need for a separate server process or operation of the system (no server).

    • SQLite does not require configuration, which means that installation or management is not required.

    • A complete SQLite database is stored in a single cross-platform disk file.

    • SQLite is very small, is lightweight, fully configured when less than 400KiB, omit optional feature configuration when less than 250KiB.

    • SQLite is self-sufficient, which means that no external dependencies are required.

    • SQLite transactions are fully ACID-compatible and allow secure access from multiple processes or threads.

    • SQLite supports the functionality of most query languages for the SQL92 (SQL2) standard.

    • SQLite is written using ansi-c and provides a simple and easy-to-use API.

    • SQLite can be run in UNIX (Linux, Mac os-x, Android, IOS) and Windows (Win32, WinCE, WinRT).

Command:

Similar to other relational databases the command resembles SQL. Commands include CREATE, SELECT, INSERT, UPDATE, DELETE, and DROP.

    1. DDL (data definition Language): Create creates a new table, a view of a table, or other objects in the database.   Drop modifies an existing database object in the database, such as a table. alter deletes the entire table, or the view of the table, or other objects in the database.
    2. DML (Data Manipulation language): Delete Creates a record.  Update to modify the record. Insert to delete the record.
    3. DQL (data Query Language): Select retrieves some records from one or more tables.

Installation:

In Windows actually do not need to install, direct decompression available (haha, very convenient!) )

On the official website http://www.sqlite.org/download.html We download sqlite-tools-win32-x86-3130000.zip such as.

Then take my computer as an example:

Create a folder in the F disk sqlite3, will download the files extracted, there will be three files (Sqlite3.exe Sqldiff.exe sqlite3_analyzer.exe), directly placed in the Sqlite3 directory can be, such as.

run: First, directly click Sqlite3.exe can

Second, or in CMD to switch to the F-Disk Sqlite3 folder also line

Verify that the installation is successful, and that you can see the current version number directly in the input sqlite3.

Command:

To get a list of available point commands, you can enter ". Help" at any time. Common commands are described below:

Command Description
. backup? Db? FILE Back up the DB database (the default is "main") to the file.
. Bail on| OFF Stop after an error occurs. The default is OFF.
. databases Lists the name and file of the attached database.
. Dump? TABLE? Dumps the database in SQL text format. If table tables are specified, only table tables matching the like pattern are dumped.
. Echo on| OFF Turns the echo command on or off.
. exit Exit the SQLite prompt.
. Explain on| OFF Turn on or off the output mode that is appropriate for the EXPLAIN. If there is no parameter, then EXPLAIN on, and EXPLAIN on.
. Header (s) on| OFF Turns the head display on or off.
. Help Displays the message.
. Import FILE TABLE Import data from file files into table tables.
. Indices? TABLE? Displays the names of all indexes. If table tables are specified, only the indexes of table tables that match the like pattern are displayed.
. Load FILE? ENTRY? Load an extension library.
. Log File|off Turn the log on or off. File files can be stderr (standard error)/stdout (standard output).
. Mode mode To set the output mode, mode can be one of the following:
  • csv comma-separated values

  • Column left-aligned columns

  • HTML HTML <table> Code

  • Insert SQL Insert (INSERT) statements for table tables

  • Line one value per row

  • list values separated by the. Separator string

  • tabs A Tab-delimited value

  • Tcl TCL list elements

. Nullvalue STRING Outputs a string string in place of a NULL value.
. Output FILENAME Send output to filename file.
. Output stdout Send output to screen.
. Print STRING ... Outputs a string literal, literally.
. prompt MAIN CONTINUE Replace the standard prompt.
. Quit Exit the SQLite prompt.
. Read FILENAME Executes the SQL in the filename file.
. Schema? TABLE? Displays the CREATE statement. If table tables are specified, only table tables matching the like pattern are displayed.
. Separator STRING Change the delimiter used by the output mode and. Import.
. Show Displays the current values for the various settings.
. Stats on| OFF Turn statistics on or off.
. Tables? PATTERN? Lists the names of the tables that match the like pattern.
. Timeout MS Try to open the locked table for MS microseconds.
. width num num Sets the column width for the "column" mode.
. Timer on| OFF Turn on or off the CPU timer measurement.

Use the. Show command to view the default settings for the SQLite command prompt

Test Example:

1. Because before entering the sqlite3, first use. Quit the SQLite
2. Use sqlite3 test.db to load or create a database
3. Then create a table with a SQL statement user
4. Then use. databases and. Tables to display the currently built database and the tables in the database

5. Finally, there are two different ways to insert two data into the data table

To view the added data with the SELECT command:

Change the output format with. Mode List|column|insert|line|tabs|tcl|csv

Use. Headers on/Off display table header default off

Use the. Width 10,20,0 to set the width of each column in the. mode column, as shown below:

With a. Timer on| OFF turn on SQL run time measurement

For more information, refer to:http://blog.csdn.net/linchunhua/article/details/7184439

Haha, for the time being so much, the other many try a lot of commands, or very simple! It's slowly coming ~

Shallow with Sqlite3 (i.)

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.