Basics of SQLite Database

Source: Internet
Author: User
SQLite is an open-source embedded Relational Database Engine for SQL database with self-contained, zero configuration, and transaction support. It features high portability, ease of use, compact structure,

SQLite is an open-source embedded Relational Database Engine for SQL database with self-contained, zero configuration, and transaction support. It features high portability, ease of use, compact structure,

1. Introduction

SQLite is an open-source embedded Relational Database Engine for SQL database with self-contained, zero configuration, and transaction support. It is highly portable, easy to use, compact, efficient, and reliable. Unlike other database management systems, SQLite is easy to install and run. In most cases, you can create, connect to, and use a database by ensuring that the binary file of SQLite exists. If you are looking for an embedded database project or solution, SQLite is definitely worth considering.

SQLite3 installation and basic operations

Simple Application of SQLite databases in Ubuntu 12.04

How to install SQLite in Ubuntu 12.04

2. Installation

SQLite on Windows

1) Go to the SQL download page:

2) download the pre-compiled Binary Package in Windows:

Sqlite-shell-win32-x86- . Zip
Sqlite-dll-win32-x86- . Zip

Note: Is the sqlite compilation version.

Decompress the zip file to your disk and add the decompressed directory to the PATH variable of the system to execute the sqlite command in the command line.

Optional: If you plan to release an application based on the sqlite database, you also need to download the source code to compile and use its API

Sqlite-amalgamation- . Zip

SQLite on Linux

Multiple Linux releases provide convenient commands to obtain SQLite:

SQLite on Mac OS X

If you are using Mac OS snow leopard or a newer version of the system, SQLite is installed on the system.

3. Create the first SQLite Database

Now that you have installed the SQLite database, create the first database. In the command line window, enter the following command to create a database named test. db.

  • Sqlite3 test. db
  • Create a table:

  • 2 columns were created.
  • This table contains a primary key field named id and a text field named value.

    Note: at least one table or view must be created for the newly created database to save the database to the disk. Otherwise, the database will not be created.

    Next, write some data to the table:

    Query data:

    Set to format the query result:

    . Mode column is set to column Display mode, And. header is used to display column names.

    Modify the table structure and add columns:

  • Create View:

  • Create an index:

  • 4. Some useful SQLite commands

    Display table structure:

  • Obtain all tables and views:

  • Sqlite>. tables
  • Obtain the index list of the specified table:

  • Export the database to an SQL file:

    Import a database from an SQL file:

  • Format output data to CSV format:

    Import data from a CSV file to a table:

  • Sqlite>. import into filename.csv] newtable
  • Back up the database:

  • Sqlite3 mytable. db. dump> backup. SQL
  • Restore database:

  • Sqlite3 mytable. db <backup. SQL
  • SQLite details: click here
    SQLite: click here

    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.