The development of lightweight database SQLite combined with PHP

Source: Internet
Author: User
Tags create index sqlite

SQLite is a lightweight database, its design goal is embedded, and has been used in many embedded products, it occupies very low resources, in embedded devices, may only need hundreds of K of memory is enough. It can support Windows/linux/unix and so on mainstream operating system, simultaneously can with many programming language combination, for instance TCL, PHP, Java and so on, also has the ODBC interface, similarly compared to MySQL, PostgreSQL the two open source world famous database management system, it processing faster than they.

SQLite, although small, supports SQL statements that are not inferior to other open source databases, and its supported SQL includes:

ATTACH DATABASE
BEGIN TRANSACTION
Comment
COMMIT TRANSACTION
COPY
CREATE INDEX
CREATE TABLE
CREATE TRIGGER
CREATE VIEW
DELETE
DETACH DATABASE
DROP INDEX
DROP TABLE
DROP TRIGGER
DROP VIEW
End TRANSACTION
EXPLAIN
Expression
INSERT
On CONFLICT clause
PRAGMA
REPLACE
ROLLBACK TRANSACTION
SELECT
UPDATE

It also supports transaction processing capabilities and so on. Others say it's like Microsoft Access, and sometimes it feels a bit like it, but in fact they are very different. For example, SQLite supports Cross-platform, simple operations, and the ability to create databases directly in many languages without the need for office support like access. If you are a very small application, or if you want to do embedded development, there is no suitable database system, then you can consider using SQLite now. Currently its latest version is 3.2.2, its official website is: http://www.sqlite.org, can get source code and documentation on it. At the same time, because the database structure is simple, the system source code is not many, also suitable to study the database system development professionals.

Now we start a simple introduction, mainly I want to clarify a few issues, one is how to install the use, and the second is how to develop with PHP.

First, installation

1. Windows platform

Downloading a file under Windows is actually a command-line program (download address: Http://www.sqlite.org/sqlite-3_2_2.zip), which includes the ability to generate database files, execute SQL queries, back up databases, and so on.
After downloading such as we unzipped to d:downloadssqlitesqlite-3_2_2 this directory, then we enter CMD, and enter this directory:
CD d:downloadssqlitesqlite-3_2_2
D:downloadssqlitesqlite-3_2_2>sqlite3 test.db
# If Test.db does not exist, then produce a database file, if there is a direct use of the database file, the equivalent of MySQL
SQLite version 3.2.2
Enter '. Help ' for instructions
Sqlite>
# SQLite prompt, if you want to see the command help input. Aid, all system commands in SQLite are. To begin with:
Sqlite>. Help
. databases List names and files of attached databases
. Dump? TABLE? ... Dump the database in a SQL text format
. Echo on| Off Turn command echo on or off
. Exit Exit this program
. Explain on| Off Turn output mode suitable to EXPLAIN on or off.
. Header (s) on| Off Turn display of headers on or off
. Help show this message
. import file TABLE Import data from FILE into TABLE
. Indices table Show Names the all indices on TABLE
. Mode mode? TABLE? Set output mode where mode is one of:
CSV comma-separated values
Column left-aligned columns. (The. Width)
HTML HTML <table> Code
Insert SQL INSERT statements for TABLE
Line one value/Line
List Values delimited by. Separator string
Tabs tab-separated values
Tcl TCL list elements
. nullvalue string Print string in place of NULL values
. Output filename Send output to FILENAME
. Output stdout Send output to the screen

Related Article

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.