SlideShare a Scribd company logo
Home Contents




Introduction to SQLite


About this tutorial

This is SQLite tutorial. It covers the SQLite database engine, sqlite3 command line tool and the SQL language

covered by the database engine. It is an introductory tutorial for the beginners. It covers SQLite 3.0 version.




SQLite database

                                                           SQLite is an embedded relational database engine. Its

                                                           developers call it a self-contained, serverless, zero-

                                                           configuration and transactional SQL database engine. It

                                                           is very popular and there are hundreds of millions copies

worldwide in use today. SQLite is used in Solaris 10 and Mac OS operating systems, iPhone or Skype. Qt4 library

has a buit-in support for the SQLite as well as the Python or the PHP language. Many popular applications use

SQLite internally such as Firefox or Amarok.


SQLite implements most of the SQL-92 standard for SQL. The SQLite engine is not a standalone process.

Instead, it is statically or dynamically linked into the application. SQLite library has a small size. It could take

less than 300 KiB. An SQLite database is a single ordinary disk file that can be located anywhere in the directory

hierarchy. It is a cross platform file. Can be used on various operating systems, both 32 and 64 bit architectures.

SQLite is created in C programming language and has bindings for many languages like C++, Java, C#, Python,

Perl, Ruby, Visual Basic, Tcl and others. The source code of SQLite is in public domain.




Definitions

A relational database is a collection of data organized in tables. There are relations among the tables. The

tables are formally described. They consist of rows and columns. SQL (Structured Query Language) is a

database computer language designed for managing data in relational database management systems. A table

is a set of values that is organized using a model of vertical columns and horizontal rows. The columns are

identified by their names. A schema of a database system is its structure described in a formal language. It

defines the tables, the fields, relationships, views, indexes, procedures, functions, queues, triggers and other

elements. A database row represents a single, implicitly structured data item in a table. It is also called a tuple

or a record. A column is a set of data values of a particular simple type, one for each row of the table. The

columns provide the structure according to which the rows are composed. A field is a single item that exists at
the intersection between one row and one column. A primary key uniquely identifies each record in the table.

A foreign key is a referential constraint between two tables. The foreign key identifies a column or a set of

columns in one (referencing) table that refers to a column or set of columns in another (referenced) table. A

trigger is a procedural code that is automatically executed in response to certain events on a particular table in

a database. A view is a specific look on data in from one or more tables. It can arrange data in some specific

order, higlight or hide some data. A view consists of a stored query accessible as a virtual table composed of the

result set of a query. Unlike ordinary tables a view does not form part of the physical schema. It is a dynamic,

virtual table computed or collated from data in the database. A transaction is an atomic unit of database

operations against the data in one or more databases. The effects of all the SQL statements in a transaction can

be either all committed to the database or all rolled back. An SQL result set is a set of rows from a database,

returned by the SELECT statement. It also contains meta-information about the query such as the column

names, and the types and sizes of each column as well. An index is a data structure that improves the speed of

data retrieval operations on a database table.




Tables used

Here we will list all the tables, that are used throughout the tutorial.




Movies database

This is the movies.db database. There are three tables. Actors, Movies and ActorsMovies.




  -- SQL for the Actors table




  BEGIN TRANSACTION;




  CREATE TABLE Actors(AId integer primary key autoincrement, Name text);




  INSERT INTO Actors VALUES(1,'Philip Seymour Hofman');




  INSERT INTO Actors VALUES(2,'Kate Shindle');
INSERT INTO Actors VALUES(3,'Kelci Stephenson');




  INSERT INTO Actors VALUES(4,'Al Pacino');




  INSERT INTO Actors VALUES(5,'Gabrielle Anwar');




  INSERT INTO Actors VALUES(6,'Patricia Arquette');




  INSERT INTO Actors VALUES(7,'Gabriel Byrne');




  INSERT INTO Actors VALUES(8,'Max von Sydow');




  INSERT INTO Actors VALUES(9,'Ellen Burstyn');




  INSERT INTO Actors VALUES(10,'Jason Miller');




  COMMIT;


This is the Actors table.




  -- SQL for the Movies table




  BEGIN TRANSACTION;




  CREATE TABLE Movies(MId integer primary key autoincrement, Title text);




  INSERT INTO Movies VALUES(1,'Capote');
INSERT INTO Movies VALUES(2,'Scent of a woman');




  INSERT INTO Movies VALUES(3,'Stigmata');




  INSERT INTO Movies VALUES(4,'Exorcist');




  INSERT INTO Movies VALUES(5,'Hamsun');




  COMMIT;


This is the Movies table.




  -- SQL for the ActorsMovies table




  BEGIN TRANSACTION;




  CREATE TABLE ActorsMovies(Id integer primary key autoincrement, AId integer, MId
  integer);




  INSERT INTO ActorsMovies VALUES(1,1,1);




  INSERT INTO ActorsMovies VALUES(2,2,1);




  INSERT INTO ActorsMovies VALUES(3,3,1);




  INSERT INTO ActorsMovies VALUES(4,4,2);




  INSERT INTO ActorsMovies VALUES(5,5,2);
INSERT INTO ActorsMovies VALUES(6,6,3);




  INSERT INTO ActorsMovies VALUES(7,7,3);




  INSERT INTO ActorsMovies VALUES(8,8,4);




  INSERT INTO ActorsMovies VALUES(9,9,4);




  INSERT INTO ActorsMovies VALUES(10,10,4);




  INSERT INTO ActorsMovies VALUES(11,8,5);




  COMMIT;


This is the ActorsMovies table.




Test database

Here we have the tables from the test.db.




  -- SQL for the Cars table




  BEGIN TRANSACTION;




  CREATE TABLE Cars(Id integer PRIMARY KEY, Name text, Cost integer);




  INSERT INTO Cars VALUES(1,'Audi',52642);




  INSERT INTO Cars VALUES(2,'Mercedes',57127);
INSERT INTO Cars VALUES(3,'Skoda',9000);




  INSERT INTO Cars VALUES(4,'Volvo',29000);




  INSERT INTO Cars VALUES(5,'Bentley',350000);




  INSERT INTO Cars VALUES(6,'Citroen',21000);




  INSERT INTO Cars VALUES(7,'Hummer',41400);




  INSERT INTO Cars VALUES(8,'Volkswagen',21600);




  COMMIT;


Cars table.




  -- SQL for the orders table




  BEGIN TRANSACTION;




  CREATE TABLE Orders(Id integer PRIMARY KEY, OrderPrice integer
  CHECK(OrderPrice>0), Customer text);




  INSERT INTO Orders(OrderPrice, Customer) VALUES(1200, "Williamson");




  INSERT INTO Orders(OrderPrice, Customer) VALUES(200, "Robertson");




  INSERT INTO Orders(OrderPrice, Customer) VALUES(40, "Robertson");
INSERT INTO Orders(OrderPrice, Customer) VALUES(1640, "Smith");




  INSERT INTO Orders(OrderPrice, Customer) VALUES(100, "Robertson");




  INSERT INTO Orders(OrderPrice, Customer) VALUES(50, "Williamson");




  INSERT INTO Orders(OrderPrice, Customer) VALUES(150, "Smith");




  INSERT INTO Orders(OrderPrice, Customer) VALUES(250, "Smith");




  INSERT INTO Orders(OrderPrice, Customer) VALUES(840, "Brown");




  INSERT INTO Orders(OrderPrice, Customer) VALUES(440, "Black");




  INSERT INTO Orders(OrderPrice, Customer) VALUES(20, "Brown");




  COMMIT;


Orders table.




  -- SQL for the Friends table




  BEGIN TRANSACTION;




  CREATE TABLE Friends(Id integer PRIMARY KEY, Name text UNIQUE NOT NULL,




                       Sex text CHECK(Sex IN ('M', 'F')));
INSERT INTO Friends VALUES(1,'Jane', 'F');




  INSERT INTO Friends VALUES(2,'Thomas', 'M');




  INSERT INTO Friends VALUES(3,'Franklin', 'M');




  INSERT INTO Friends VALUES(4,'Elisabeth', 'F');




  INSERT INTO Friends VALUES(5,'Mary', 'F');




  INSERT INTO Friends VALUES(6,'Lucy', 'F');




  INSERT INTO Friends VALUES(7,'Jack', 'M');




  COMMIT;


Friends table.




  -- SQL for the Customers, Reservations tables




  BEGIN TRANSACTION;




  CREATE TABLE IF NOT EXISTS Customers(CustomerId integer PRIMARY KEY, Name text);




  INSERT INTO Customers(Name) VALUES('Paul Novak');




  INSERT INTO Customers(Name) VALUES('Terry Neils');
INSERT INTO Customers(Name) VALUES('Jack Fonda');




  INSERT INTO Customers(Name) VALUES('Tom Willis');




  CREATE TABLE IF NOT EXISTS Reservations(Id integer PRIMARY KEY,




                                          CustomerId integer, Day text);




  INSERT INTO Reservations(CustomerId, Day) VALUES(1, '2009-22-11');




  INSERT INTO Reservations(CustomerId, Day) VALUES(2, '2009-28-11');




  INSERT INTO Reservations(CustomerId, Day) VALUES(2, '2009-29-11');




  INSERT INTO Reservations(CustomerId, Day) VALUES(1, '2009-29-11');




  INSERT INTO Reservations(CustomerId, Day) VALUES(3, '2009-02-12');




  COMMIT;


Customers and Reservations.




  -- SQL for the Names table




  BEGIN TRANSACTION;
CREATE TABLE Names(Id integer, Name text);




  INSERT INTO Names VALUES(1,'Tom');




  INSERT INTO Names VALUES(2,'Lucy');




  INSERT INTO Names VALUES(3,'Frank');




  INSERT INTO Names VALUES(4,'Jane');




  INSERT INTO Names VALUES(5,'Robert');




  COMMIT;


Names table.




  -- SQL for the Books table




  BEGIN TRANSACTION;




  CREATE TABLE Books(Id integer PRIMARY KEY, Title text, Author text,




                       Isbn text default 'not available');




  INSERT INTO Books VALUES(1,'War and Peace','Leo Tolstoy','978-0345472403');




  INSERT INTO Books VALUES(2,'The Brothers Karamazov','Fyodor
  Dostoyevsky','978-0486437910');
INSERT INTO Books VALUES(3,'Crime and Punishment','Fyodor
  Dostoyevsky','978-1840224306');




  COMMIT;


Books table.

More Related Content

What's hot

Module 3
Module 3Module 3
Module 3
cs19club
 
Ch04
Ch04Ch04
Ch04
cs19club
 
Ch05
Ch05Ch05
Ch05
cs19club
 
SQL Tutorial for BCA-2
SQL Tutorial for BCA-2SQL Tutorial for BCA-2
SQL Tutorial for BCA-2
Raj vardhan
 
SQL- Introduction to PL/SQL
SQL- Introduction to  PL/SQLSQL- Introduction to  PL/SQL
SQL- Introduction to PL/SQL
Vibrant Technologies & Computers
 
vFabric SQLFire Introduction
vFabric SQLFire IntroductionvFabric SQLFire Introduction
vFabric SQLFire Introduction
Jags Ramnarayan
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
Vibrant Technologies & Computers
 
SQL Differences SQL Interview Questions
SQL Differences  SQL Interview QuestionsSQL Differences  SQL Interview Questions
SQL Differences SQL Interview Questions
MLR Institute of Technology
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
Dhananjay Goel
 
DDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleDDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using Oracle
Farhan Aslam
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
Balqees Al.Mubarak
 
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | EdurekaSQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
Edureka!
 
Extensible Data Modeling
Extensible Data ModelingExtensible Data Modeling
Extensible Data Modeling
Karwin Software Solutions LLC
 
Sql Basics | Edureka
Sql Basics | EdurekaSql Basics | Edureka
Sql Basics | Edureka
Edureka!
 
Intro to T-SQL - 1st session
Intro to T-SQL - 1st sessionIntro to T-SQL - 1st session
Intro to T-SQL - 1st session
Medhat Dawoud
 
Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginnersISsoft
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
Stewart Rogers
 
Intro to T-SQL – 2nd session
Intro to T-SQL – 2nd sessionIntro to T-SQL – 2nd session
Intro to T-SQL – 2nd session
Medhat Dawoud
 

What's hot (20)

Sql basics
Sql  basicsSql  basics
Sql basics
 
Module 3
Module 3Module 3
Module 3
 
Ch04
Ch04Ch04
Ch04
 
Ch05
Ch05Ch05
Ch05
 
SQL Tutorial for BCA-2
SQL Tutorial for BCA-2SQL Tutorial for BCA-2
SQL Tutorial for BCA-2
 
SQL- Introduction to PL/SQL
SQL- Introduction to  PL/SQLSQL- Introduction to  PL/SQL
SQL- Introduction to PL/SQL
 
vFabric SQLFire Introduction
vFabric SQLFire IntroductionvFabric SQLFire Introduction
vFabric SQLFire Introduction
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
SQL Differences SQL Interview Questions
SQL Differences  SQL Interview QuestionsSQL Differences  SQL Interview Questions
SQL Differences SQL Interview Questions
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 
DDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleDDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using Oracle
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | EdurekaSQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
 
Extensible Data Modeling
Extensible Data ModelingExtensible Data Modeling
Extensible Data Modeling
 
Sql Basics | Edureka
Sql Basics | EdurekaSql Basics | Edureka
Sql Basics | Edureka
 
Intro to T-SQL - 1st session
Intro to T-SQL - 1st sessionIntro to T-SQL - 1st session
Intro to T-SQL - 1st session
 
Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginners
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Intro to T-SQL – 2nd session
Intro to T-SQL – 2nd sessionIntro to T-SQL – 2nd session
Intro to T-SQL – 2nd session
 

Viewers also liked

Sq lite functions
Sq lite functionsSq lite functions
Sq lite functionspunu_82
 
Creating, altering and dropping tables
Creating, altering and dropping tablesCreating, altering and dropping tables
Creating, altering and dropping tablespunu_82
 
SCDN 1
SCDN 1SCDN 1
SCDN 1scdn
 
Java one 2010
Java one 2010Java one 2010
Java one 2010
scdn
 
The sqlite3 commnad line tool
The sqlite3 commnad line toolThe sqlite3 commnad line tool
The sqlite3 commnad line toolpunu_82
 
мясной дом Бородина.
мясной дом Бородина.мясной дом Бородина.
мясной дом Бородина.
Санечка Бравова
 
第5回SCDN - Things that become possible with HTML5
第5回SCDN - Things that become possible with HTML5第5回SCDN - Things that become possible with HTML5
第5回SCDN - Things that become possible with HTML5scdn
 

Viewers also liked (7)

Sq lite functions
Sq lite functionsSq lite functions
Sq lite functions
 
Creating, altering and dropping tables
Creating, altering and dropping tablesCreating, altering and dropping tables
Creating, altering and dropping tables
 
SCDN 1
SCDN 1SCDN 1
SCDN 1
 
Java one 2010
Java one 2010Java one 2010
Java one 2010
 
The sqlite3 commnad line tool
The sqlite3 commnad line toolThe sqlite3 commnad line tool
The sqlite3 commnad line tool
 
мясной дом Бородина.
мясной дом Бородина.мясной дом Бородина.
мясной дом Бородина.
 
第5回SCDN - Things that become possible with HTML5
第5回SCDN - Things that become possible with HTML5第5回SCDN - Things that become possible with HTML5
第5回SCDN - Things that become possible with HTML5
 

Similar to Introduction to sq lite

ORACLE PL SQL
ORACLE PL SQLORACLE PL SQL
ORACLE PL SQL
Srinath Maharana
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
Zespół Szkół nr 26
 
Sql
SqlSql
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
MLG College of Learning, Inc
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
DraguClaudiu
 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1sagaroceanic11
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
TamiratDejene1
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
mayurisonawane29
 
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDSORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
Newyorksys.com
 
Physical Design and Development
Physical Design and DevelopmentPhysical Design and Development
Physical Design and Development
Er. Nawaraj Bhandari
 
Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
Dr. C.V. Suresh Babu
 
Difference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleDifference Between Sql - MySql and Oracle
Difference Between Sql - MySql and Oracle
Steve Johnson
 
SQL cheat sheet.pdf
SQL cheat sheet.pdfSQL cheat sheet.pdf
SQL cheat sheet.pdf
NiravPanchal50
 
Presentation1
Presentation1Presentation1
Presentation1
ahsan-1252
 

Similar to Introduction to sq lite (20)

ORACLE PL SQL
ORACLE PL SQLORACLE PL SQL
ORACLE PL SQL
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Sql
SqlSql
Sql
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1
 
12 SQL
12 SQL12 SQL
12 SQL
 
12 SQL
12 SQL12 SQL
12 SQL
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 
Module02
Module02Module02
Module02
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
 
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDSORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
 
Physical Design and Development
Physical Design and DevelopmentPhysical Design and Development
Physical Design and Development
 
Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
 
Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
 
Difference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleDifference Between Sql - MySql and Oracle
Difference Between Sql - MySql and Oracle
 
SQL cheat sheet.pdf
SQL cheat sheet.pdfSQL cheat sheet.pdf
SQL cheat sheet.pdf
 
Presentation1
Presentation1Presentation1
Presentation1
 

Recently uploaded

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 

Recently uploaded (20)

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 

Introduction to sq lite

  • 1. Home Contents Introduction to SQLite About this tutorial This is SQLite tutorial. It covers the SQLite database engine, sqlite3 command line tool and the SQL language covered by the database engine. It is an introductory tutorial for the beginners. It covers SQLite 3.0 version. SQLite database SQLite is an embedded relational database engine. Its developers call it a self-contained, serverless, zero- configuration and transactional SQL database engine. It is very popular and there are hundreds of millions copies worldwide in use today. SQLite is used in Solaris 10 and Mac OS operating systems, iPhone or Skype. Qt4 library has a buit-in support for the SQLite as well as the Python or the PHP language. Many popular applications use SQLite internally such as Firefox or Amarok. SQLite implements most of the SQL-92 standard for SQL. The SQLite engine is not a standalone process. Instead, it is statically or dynamically linked into the application. SQLite library has a small size. It could take less than 300 KiB. An SQLite database is a single ordinary disk file that can be located anywhere in the directory hierarchy. It is a cross platform file. Can be used on various operating systems, both 32 and 64 bit architectures. SQLite is created in C programming language and has bindings for many languages like C++, Java, C#, Python, Perl, Ruby, Visual Basic, Tcl and others. The source code of SQLite is in public domain. Definitions A relational database is a collection of data organized in tables. There are relations among the tables. The tables are formally described. They consist of rows and columns. SQL (Structured Query Language) is a database computer language designed for managing data in relational database management systems. A table is a set of values that is organized using a model of vertical columns and horizontal rows. The columns are identified by their names. A schema of a database system is its structure described in a formal language. It defines the tables, the fields, relationships, views, indexes, procedures, functions, queues, triggers and other elements. A database row represents a single, implicitly structured data item in a table. It is also called a tuple or a record. A column is a set of data values of a particular simple type, one for each row of the table. The columns provide the structure according to which the rows are composed. A field is a single item that exists at
  • 2. the intersection between one row and one column. A primary key uniquely identifies each record in the table. A foreign key is a referential constraint between two tables. The foreign key identifies a column or a set of columns in one (referencing) table that refers to a column or set of columns in another (referenced) table. A trigger is a procedural code that is automatically executed in response to certain events on a particular table in a database. A view is a specific look on data in from one or more tables. It can arrange data in some specific order, higlight or hide some data. A view consists of a stored query accessible as a virtual table composed of the result set of a query. Unlike ordinary tables a view does not form part of the physical schema. It is a dynamic, virtual table computed or collated from data in the database. A transaction is an atomic unit of database operations against the data in one or more databases. The effects of all the SQL statements in a transaction can be either all committed to the database or all rolled back. An SQL result set is a set of rows from a database, returned by the SELECT statement. It also contains meta-information about the query such as the column names, and the types and sizes of each column as well. An index is a data structure that improves the speed of data retrieval operations on a database table. Tables used Here we will list all the tables, that are used throughout the tutorial. Movies database This is the movies.db database. There are three tables. Actors, Movies and ActorsMovies. -- SQL for the Actors table BEGIN TRANSACTION; CREATE TABLE Actors(AId integer primary key autoincrement, Name text); INSERT INTO Actors VALUES(1,'Philip Seymour Hofman'); INSERT INTO Actors VALUES(2,'Kate Shindle');
  • 3. INSERT INTO Actors VALUES(3,'Kelci Stephenson'); INSERT INTO Actors VALUES(4,'Al Pacino'); INSERT INTO Actors VALUES(5,'Gabrielle Anwar'); INSERT INTO Actors VALUES(6,'Patricia Arquette'); INSERT INTO Actors VALUES(7,'Gabriel Byrne'); INSERT INTO Actors VALUES(8,'Max von Sydow'); INSERT INTO Actors VALUES(9,'Ellen Burstyn'); INSERT INTO Actors VALUES(10,'Jason Miller'); COMMIT; This is the Actors table. -- SQL for the Movies table BEGIN TRANSACTION; CREATE TABLE Movies(MId integer primary key autoincrement, Title text); INSERT INTO Movies VALUES(1,'Capote');
  • 4. INSERT INTO Movies VALUES(2,'Scent of a woman'); INSERT INTO Movies VALUES(3,'Stigmata'); INSERT INTO Movies VALUES(4,'Exorcist'); INSERT INTO Movies VALUES(5,'Hamsun'); COMMIT; This is the Movies table. -- SQL for the ActorsMovies table BEGIN TRANSACTION; CREATE TABLE ActorsMovies(Id integer primary key autoincrement, AId integer, MId integer); INSERT INTO ActorsMovies VALUES(1,1,1); INSERT INTO ActorsMovies VALUES(2,2,1); INSERT INTO ActorsMovies VALUES(3,3,1); INSERT INTO ActorsMovies VALUES(4,4,2); INSERT INTO ActorsMovies VALUES(5,5,2);
  • 5. INSERT INTO ActorsMovies VALUES(6,6,3); INSERT INTO ActorsMovies VALUES(7,7,3); INSERT INTO ActorsMovies VALUES(8,8,4); INSERT INTO ActorsMovies VALUES(9,9,4); INSERT INTO ActorsMovies VALUES(10,10,4); INSERT INTO ActorsMovies VALUES(11,8,5); COMMIT; This is the ActorsMovies table. Test database Here we have the tables from the test.db. -- SQL for the Cars table BEGIN TRANSACTION; CREATE TABLE Cars(Id integer PRIMARY KEY, Name text, Cost integer); INSERT INTO Cars VALUES(1,'Audi',52642); INSERT INTO Cars VALUES(2,'Mercedes',57127);
  • 6. INSERT INTO Cars VALUES(3,'Skoda',9000); INSERT INTO Cars VALUES(4,'Volvo',29000); INSERT INTO Cars VALUES(5,'Bentley',350000); INSERT INTO Cars VALUES(6,'Citroen',21000); INSERT INTO Cars VALUES(7,'Hummer',41400); INSERT INTO Cars VALUES(8,'Volkswagen',21600); COMMIT; Cars table. -- SQL for the orders table BEGIN TRANSACTION; CREATE TABLE Orders(Id integer PRIMARY KEY, OrderPrice integer CHECK(OrderPrice>0), Customer text); INSERT INTO Orders(OrderPrice, Customer) VALUES(1200, "Williamson"); INSERT INTO Orders(OrderPrice, Customer) VALUES(200, "Robertson"); INSERT INTO Orders(OrderPrice, Customer) VALUES(40, "Robertson");
  • 7. INSERT INTO Orders(OrderPrice, Customer) VALUES(1640, "Smith"); INSERT INTO Orders(OrderPrice, Customer) VALUES(100, "Robertson"); INSERT INTO Orders(OrderPrice, Customer) VALUES(50, "Williamson"); INSERT INTO Orders(OrderPrice, Customer) VALUES(150, "Smith"); INSERT INTO Orders(OrderPrice, Customer) VALUES(250, "Smith"); INSERT INTO Orders(OrderPrice, Customer) VALUES(840, "Brown"); INSERT INTO Orders(OrderPrice, Customer) VALUES(440, "Black"); INSERT INTO Orders(OrderPrice, Customer) VALUES(20, "Brown"); COMMIT; Orders table. -- SQL for the Friends table BEGIN TRANSACTION; CREATE TABLE Friends(Id integer PRIMARY KEY, Name text UNIQUE NOT NULL, Sex text CHECK(Sex IN ('M', 'F')));
  • 8. INSERT INTO Friends VALUES(1,'Jane', 'F'); INSERT INTO Friends VALUES(2,'Thomas', 'M'); INSERT INTO Friends VALUES(3,'Franklin', 'M'); INSERT INTO Friends VALUES(4,'Elisabeth', 'F'); INSERT INTO Friends VALUES(5,'Mary', 'F'); INSERT INTO Friends VALUES(6,'Lucy', 'F'); INSERT INTO Friends VALUES(7,'Jack', 'M'); COMMIT; Friends table. -- SQL for the Customers, Reservations tables BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS Customers(CustomerId integer PRIMARY KEY, Name text); INSERT INTO Customers(Name) VALUES('Paul Novak'); INSERT INTO Customers(Name) VALUES('Terry Neils');
  • 9. INSERT INTO Customers(Name) VALUES('Jack Fonda'); INSERT INTO Customers(Name) VALUES('Tom Willis'); CREATE TABLE IF NOT EXISTS Reservations(Id integer PRIMARY KEY, CustomerId integer, Day text); INSERT INTO Reservations(CustomerId, Day) VALUES(1, '2009-22-11'); INSERT INTO Reservations(CustomerId, Day) VALUES(2, '2009-28-11'); INSERT INTO Reservations(CustomerId, Day) VALUES(2, '2009-29-11'); INSERT INTO Reservations(CustomerId, Day) VALUES(1, '2009-29-11'); INSERT INTO Reservations(CustomerId, Day) VALUES(3, '2009-02-12'); COMMIT; Customers and Reservations. -- SQL for the Names table BEGIN TRANSACTION;
  • 10. CREATE TABLE Names(Id integer, Name text); INSERT INTO Names VALUES(1,'Tom'); INSERT INTO Names VALUES(2,'Lucy'); INSERT INTO Names VALUES(3,'Frank'); INSERT INTO Names VALUES(4,'Jane'); INSERT INTO Names VALUES(5,'Robert'); COMMIT; Names table. -- SQL for the Books table BEGIN TRANSACTION; CREATE TABLE Books(Id integer PRIMARY KEY, Title text, Author text, Isbn text default 'not available'); INSERT INTO Books VALUES(1,'War and Peace','Leo Tolstoy','978-0345472403'); INSERT INTO Books VALUES(2,'The Brothers Karamazov','Fyodor Dostoyevsky','978-0486437910');
  • 11. INSERT INTO Books VALUES(3,'Crime and Punishment','Fyodor Dostoyevsky','978-1840224306'); COMMIT; Books table.