1. Trang chủ
  2. » Công Nghệ Thông Tin

sqlite tutorial

169 655 1
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 169
Dung lượng 2,82 MB

Nội dung

Sqlite tutorial. Tài liệu dùng để học sqlite bằng tiếng anh được viết bởi tutorialspoint.

SQLite Tutorial i SQLITE TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com TUTORIALS POINT Simply Easy Learning ABOUT THE TUTORIAL SQLite Tutorial SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain. This tutorial will give you quick start with SQLite and make you comfortable with SQLite programming. Audience This reference has been prepared for the beginners to help them understand the basic to advanced concepts related to SQLite Database Engine. Prerequisites Before you start doing practice with various types of examples given in this reference, I'm making an assumption that you are already aware about what is database, specially RDBMS and what is a computer programming language. Copyright & Disclaimer Notice All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the accuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site or this tutorial content contains some errors, please contact us at webmaster@tutorialspoint.com TUTORIALS POINT Simply Easy Learning Table of Content SQLite Tutorial . 2 Audience 2 Prerequisites 2 Copyright & Disclaimer Notice 2 SQLite Overview 11 What is SQLite? . 11 Why SQLite? 11 History: . 12 SQLite Limitations: . 12 SQLite Commands: 12 DDL - Data Defination Language: 12 DML - Data Manipulation Language: 12 DQL - Data Query Language: 13 SQLite Installation 14 Install SQLite On Windows . 14 Install SQLite On Linux . 14 Install SQLite On Mac OS X . 15 SQLite Commands . 16 Formatting output . 18 The sqlite_master Table . 18 SQLite Syntax 19 Case Sensitivity 19 Comments 19 SQLite Statements . 19 SQLite ANALYZE Statement: . 19 SQLite AND/OR Clause: 20 SQLite ALTER TABLE Statement: . 20 SQLite ALTER TABLE Statement (Rename) : . 20 SQLite ATTACH DATABASE Statement: . 20 SQLite BEGIN TRANSACTION Statement: . 20 SQLite BETWEEN Clause: 20 SQLite COMMIT Statement: 20 SQLite CREATE INDEX Statement: 20 SQLite CREATE UNIQUE INDEX Statement: 20 SQLite CREATE TABLE Statement: 21 SQLite CREATE TRIGGER Statement : 21 SQLite CREATE VIEW Statement : . 21 TUTORIALS POINT Simply Easy Learning SQLite CREATE VIRTUAL TABLE Statement: 21 SQLite COMMIT TRANSACTION Statement: 21 SQLite COUNT Clause: . 21 SQLite DELETE Statement: . 21 SQLite DETACH DATABASE Statement: 22 SQLite DISTINCT Clause: 22 SQLite DROP INDEX Statement : 22 SQLite DROP TABLE Statement: 22 SQLite DROP VIEW Statement : . 22 SQLite DROP TRIGGER Statement : 22 SQLite EXISTS Clause: . 22 SQLite EXPLAIN Statement : . 22 SQLite GLOB Clause: 22 SQLite GROUP BY Clause: . 22 SQLite HAVING Clause: 23 SQLite INSERT INTO Statement: 23 SQLite IN Clause: 23 SQLite Like Clause: . 23 SQLite NOT IN Clause: 23 SQLite ORDER BY Clause: . 23 SQLite PRAGMA Statement: . 23 SQLite RELEASE SAVEPOINT Statement: . 24 SQLite REINDEX Statement: . 24 SQLite ROLLBACK Statement: 24 SQLite SAVEPOINT Statement: 24 SQLite SELECT Statement: . 24 SQLite UPDATE Statement: 24 SQLite VACUUM Statement: . 24 SQLite WHERE Clause: . 24 SQLite Data Type 25 SQLite Storage Classes: 25 SQLite Affinity Type: 25 SQLite Affinity and Type Names: . 26 Boolean Datatype: 27 Date and Time Datatype: . 27 SQLite Create Database 28 Syntax: . 28 Example: 28 The .dump Command . 29 TUTORIALS POINT Simply Easy Learning SQLite Attach Database . 30 Syntax: . 30 Example: 30 SQLite Detach Database . 31 Syntax: . 31 Example: 31 SQLite Create Table 32 Syntax: . 32 Example: 32 SQLite Drop Table . 34 Syntax: . 34 Example: 34 SQLite Insert Query . 35 Syntax: . 35 Example: 35 Populate one table using another table: . 36 SQLite Select Query 37 Syntax: . 37 Example: 37 Setting output column width: 38 Schema Information: 38 SQLite Operators . 40 SQLite Arithmetic Operators: . 40 Example . 41 SQLite Comparison Operators: 41 Example . 42 SQLite Logical Operators: 43 Example . 43 SQLite Bitwise Operators: 45 Example . 46 SQLite Expressions . 48 Syntax: . 48 SQLite - Boolean Expressions: 48 SQLite - Numeric Expression: 49 SQLite - Date Expressions: 49 SQLite Where Clause 50 Syntax: . 50 Example: 50 SQLite AND and OR Operator . 53 TUTORIALS POINT Simply Easy Learning The AND Operator: 53 Syntax: . 53 Example: 53 The OR Operator: 54 Syntax: . 54 Example: 54 SQLite Update Query . 55 Syntax: . 55 Example: 55 SQLite Delete Query 57 Syntax: . 57 Example: 57 SQLite Like Clause 59 Syntax: . 59 Example: 60 SQLite Glob Clause . 62 Syntax: . 62 Example: 63 SQLite LIMIT Clause 65 Syntax: . 65 Example: 65 SQLite Order By Clause . 67 Syntax: . 67 Example: 67 SQLite Group By Clause 69 Syntax: . 69 Example: 69 SQLite Having Clause 72 Syntax: . 72 Example: 72 SQLite Distinct Keyword 74 Syntax: . 74 Example: 74 SQLite PRAGMA . 76 Syntax: . 76 auto_vacuum Pragma 76 cache_size Pragma 77 case_sensitive_like Pragma . 77 count_changes Pragma . 77 TUTORIALS POINT Simply Easy Learning database_list Pragma . 77 encoding Pragma . 77 freelist_count Pragma 77 index_info Pragma . 78 index_list Pragma . 78 journal_mode Pragma 78 max_page_count Pragma 78 page_count Pragma . 79 page_size Pragma . 79 parser_trace Pragma 79 recursive_triggers Pragma . 79 schema_version Pragma 79 secure_delete Pragma . 79 sql_trace Pragma . 80 synchronous Pragma . 80 temp_store Pragma 80 temp_store_directory Pragma 80 user_version Pragma . 81 writable_schema Pragma . 81 SQLite Constraints . 82 NOT NULL Constraint 82 EXAMPLE: . 82 DEFAULT Constraint 82 EXAMPLE: . 83 UNIQUE Constraint 83 EXAMPLE: . 83 PRIMARY KEY Constraint . 83 EXAMPLE: . 83 CHECK Constraint . 84 EXAMPLE: . 84 Dropping Constraints: . 84 SQLite Joins 85 The CROSS JOIN 86 The INNER JOIN 86 The OUTER JOIN 87 SQLite UNIONS Clause . 89 Syntax: . 89 Example: 89 COMPANY TABLE . 89 TUTORIALS POINT Simply Easy Learning The UNION ALL Clause: 91 Syntax: . 91 Example: 91 SQLite NULL Values 93 Syntax: . 93 Example: 93 SQLite ALIAS Syntax . 95 Syntax: . 95 Example: 95 SQLite Triggers 97 Syntax: . 97 Example . 98 Listing TRIGGERS . 99 Dropping TRIGGERS . 99 SQLite Indexes 100 The CREATE INDEX Command: . 100 Single-Column Indexes: . 100 Unique Indexes: . 100 Composite Indexes: . 101 Implicit Indexes: . 101 Example . 101 The DROP INDEX Command: . 101 When should indexes be avoided? 102 SQLite Alter Command 103 Syntax: . 103 Example: 103 SQLite Truncate Table . 105 Syntax: . 105 Example: 105 SQLite Views . 106 Creating Views: 106 Example: 106 Dropping Views: . 107 SQLite TRANSACTIONS . 108 Properties of Transactions: 108 Transaction Control: . 108 The BEGIN TRANSACTION Command: 109 The COMMIT Command: . 109 The ROLLBACK Command: 109 TUTORIALS POINT Simply Easy Learning Example: 109 SQLite Sub Queries . 111 Subqueries with the SELECT Statement: . 111 Example: 112 Subqueries with the INSERT Statement: . 112 Example: 112 Subqueries with the UPDATE Statement: 113 Example: 113 Subqueries with the DELETE Statement: . 113 Example: 113 SQLite AUTOINCREMENT 115 Syntax: . 115 Example: 115 SQLite Injection 117 Preventing SQL Injection: . 117 SQLite Explain . 119 Syntax: . 119 Example: 119 SQLite Vacuum 122 Manual VACUUM . 122 Auto-VACCUM . 122 SQLite Date & Time . 124 Time Strings: 124 Modifiers . 125 Formatters: . 125 Examples . 126 SQLite Useful Functions 128 SQLite COUNT Function 129 SQLite MAX Function . 129 SQLite MIN Function 129 SQLite AVG Function . 129 SQLite SUM Function . 130 SQLite RANDOM Function . 130 SQLite ABS Function . 130 SQLite UPPER Function 130 SQLite LOWER Function . 131 SQLite LENGTH Function 131 SQLite sqlite_version Function . 131 SQLite C/C++ Tutorial 132 . SQLite Tutorial i SQLITE TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com TUTORIALS POINT Simply Easy Learning ABOUT THE TUTORIAL. you sqlite3 .def, sqlite3 .dll and sqlite3 .exe files.  Add C:> ;sqlite in your PATH environment variable and finally go to the command prompt and issue sqlite3

Ngày đăng: 02/08/2013, 01:52

Xem thêm

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w