Lightweight database SQLite combined with PHP development _php Tutorial

Source: Internet
Author: User
SQLite is a lightweight database, it is designed to be embedded, and has been used in many embedded products, it occupies a very low resource, in the embedded device, may only need hundreds of K of memory is enough. It can support Windows/linux/unix and other mainstream operating systems, and can be combined with many programming languages, such as Tcl, PHP (as the current mainstream development language), Java, and ODBC interface, the same compared to MySQL (and PHP collocation of the best combination), PostgreSQL, the two open source world-famous database management system, is processing faster than they do.

Although SQLite is small, the supported SQL statements are not inferior to other open source databases, and the SQL it supports 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 transactional processing functions and so on. Others say it's like Microsoft's access (the favorite of small sites), and sometimes it feels a bit like it, but in fact they differ greatly. For example, SQLite supports cross-platform, easy to use, and can create databases directly in many languages, rather than requiring office support like access (small Web favorites). If you are a very small application, or if you want to do embedded development, there is no suitable database system, then you can now consider using SQLite. Currently its latest version is 3.2.2, its official website is: http://www.sqlite.org, can obtain the source code and the document. At the same time because the database structure is simple, the system source code is not many, also suitable for the study of database system development professionals.

Now we start with a simple introduction, mainly I want to explain a few questions, one is how to install the use, the second is how to work with PHP (as the mainstream development language now) combined development.

First, installation

1. Windows platform

Downloading files under Windows is actually a command-line program (download address: http://www.sqlite.org/sqlite-3_2_2.zip), which is used to include generating database files, executing SQL queries, Backup database and so on.
After downloading, for example, we extract to d:downloadssqlitesqlite-3_2_2 this directory, then we go to cmd, and enter the directory:
CD d:downloadssqlitesqlite-3_2_2
D:d Ownloadssqlitesqlite-3_2_2>sqlite3 test.db
# If Test.db does not exist, then a database file is generated, and if it exists, the database file is used directly, which is equivalent to MySQL ( and the best combination of PHP collocation), use the
SQLite version 3.2.2
Enter ". Help" for instructions
sqlite>
# SQLite prompt, If you want to see the command help input, all system commands in SQLite are. Starting with:
sqlite>. Help
. Databases List names and files of attached databases
. Dump? TABLE? ... Dump the database in an SQL text Format
. Echo on| Off Turn command echo on or off
. Exit exit this program
. Explain on| Off Turn output mode suitable for 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 to TABLE
.indices table Show Names of all indices on TABLE

http://www.bkjia.com/PHPjc/508728.html www.bkjia.com true http://www.bkjia.com/PHPjc/508728.html techarticle SQLite is a lightweight database, it is designed to be embedded, and it has been used in many embedded products, it occupies very low resources in embedded devices ...

  • 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.