SlideShare una empresa de Scribd logo
1 de 24
Proven Database for
IIOT Applications
SQLite
Learn the Music of Database
SESSION #1
SQLite Basics
www.inforepos.com
Agenda
• Install & Configuring SQLite
• DOT (.) Commands
• Accessing Database
• Basics of SQLite
• Data Types
• Operators
• DQL (SELECT)
• DML (INSERT, UPDATE, DELETE)
www.inforepos.com
Install /Configure SQLite
• Unzip both the folders “sqlite-dll-win64-x64-3170000.zip” & “sqlite-tools-
win32-x86-3170000.zip”. Merge all files and place them in one folder, say
“C:sqlite3”
• Add PATH parameter in system environment variables “C:sqlite3”
• Open command prompt and go to “C:sqlite3” run sqlite3.exe
There are two types of command interpreters in SQLite –
• Free-form SQL statement
• Recognized by SQLite program and expects SQL native words at the start of the statement
• Dot-form statement
• Identified by SQLite command-line program (sqlite3.exe) and starts with dot-command
www.inforepos.com
SQLite DOT(.) Commands
• A dot-command must begin with the "." at the left margin with no preceding
whitespace.
• The dot-command must be entirely contained on a single input line.
• A dot-command cannot occur in the middle of an ordinary SQL statement. In
other words, a dot-command cannot occur at a continuation prompt.
• Dot-commands do not recognize comments.
• Eg.
• .open
• .tables
• .output
• .schema …. many
www.inforepos.com
Accessing Database
OPEN, ATTACH, DETACH database
• ATTACH [DATABASE] filename AS database_name;
• sqlite3>sqlite3 sensorsdb.db
• sqlite3> .database
seq name file
--- --------------- ------------------------
0 main D:sqlite3sensorsdb.db
www.inforepos.com
Accessing Database
OPEN, ATTACH, DETACH database
• ATTACH customerdb AS custdb;
• ATTACH DATABASE 'smartihomedb.db' as 'ihomedb';
• ATTACH DATABASE 'smartihealthdb.db' as 'ihealthdb';
• sqlite> .database
seq name file
--- --------------- ------------------------
0 main D:/sqlite3/sensorsdb.db
2 custdb D:/sqlite3/customerdb.db
3 ihomedb D:/sqlite3/smartihomedb.db
4 ihealthdb D:/sqlite3/smartihealthdb.db
www.inforepos.com
OPEN, ATTACH, DETACH database
• DETACH DATABASE 'Alias-Name';
• sqlite3> detach DATABASE sensorsdb;
• sqlite3> .database
• .open ?FILENAME?
• sqlite3> .open D:/sqlite3/smartihomedb.db
• sqlite3> .databases
seq name file
--- --------------- ------------------------------------
0 main D:/sqlite3/smartihomedb.db
www.inforepos.com
SQLite Data Types
• A data type specifies a particular type of data, such as integer, floating-point,
Boolean etc.
• A data type also specifies the possible values for that type, the operations that
can be performed on that type and the way the values of that type are stored.
NULL The value is a NULL value.
INTEGER
The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on
the magnitude of the value.
REAL
The value is a floating point value, stored as an 8-byte IEEE floating point
number.
TEXT
The value is a text string, stored using the database encoding (UTF-8, UTF-
16BE or UTF-16LE)
BLOB The value is a blob of data, stored exactly as it was input.
www.inforepos.com
SQLite Data Types – Type Affinity Examples
Example Type names From The
CREATE TABLE Statement
or CAST Expression
Resulting Affinity
Rule Used To
Determine Affinity
INT
INTEGER
TINYINT
SMALLINT
MEDIUMINT
BIGINT
UNSIGNED BIG INT
INT2
INT8
INTEGER 1
CHARACTER(20)
VARCHAR(255)
VARYING CHARACTER(255)
NCHAR(55)
NATIVE CHARACTER(70)
NVARCHAR(100)
TEXT
CLOB
TEXT 2
BLOB
no datatype specified
NONE 3
REAL
DOUBLE
DOUBLE PRECISION
FLOAT
REAL 4
NUMERIC
DECIMAL(10,5)
BOOLEAN
DATE | DATETIME
NUMERIC 5
www.inforepos.com
SQLite Operators
• Arithmetic Operators
• Comparison Operators
• Boolean Operators
• LIKE Operator
• Between Operator
• IN and NOT IN Operators
• EXISTS Operator
www.inforepos.com
SQLite Operators : Highest to Lowest precedence
• ||
• * / %
• + -
• << >> & |
• < <= > >=
• = == != <> IS IS NOT IN LIKE GLOB MATCH REGEXP
• AND
• OR
• Supported unary prefix operators are these: - + ~ NOT
www.inforepos.com
DQL
SQLite SELECT Query
• The SELECT statement is used to make a simple query from a database or a
complicated query against some criteria. A SELECT statement does not make
any changes to the database / database objects.
• A query or SELECT statement is a command which gives instructions to a
database to produce certain information(s) from the table in its memory. The
SELECT command starts with the keyword SELECT.
SELECT [ALL | DISTINCT] result [FROM table-list]
[WHERE expr]
[GROUP BY expr-list]
[HAVING expr]
[compound-op select]*
[ORDER BY sort-expr-list]
[LIMIT integer [(OFFSET|,) integer]]
www.inforepos.com
DQL
SQLite SELECT Query
• Parameters
Clause Operation perform Input Value
WHERE Used to restrict Expression or condition
DISTINCT Used to restrict List of columns
FROM Joins List of tables
GROUP BY Used to restrict List of columns
ORDER BY List of columns
HAVING Used to restrict Expression or condition
LIMIT Used to restrict Integer value
OFFSET Used to restrict Integer value
www.inforepos.com
DQL
SQLite SELECT Query
Basic Arithmetic Operations without any Table:
• SELECT 6+15;
• SELECT 5*15;
• SELECT 5+2-3*4/6;
SELECT Operations Using Tables:
• SELECT * FROM sensor_list;
• SELECT street_address, city FROM locations; (Select required columns)
• SELECT region_name AS "Name of the Region" FROM regions; (Renaming column names)
• SELECT r.region_name FROM regions r; (Select using alias)
• SELECT * FROM locations LIMIT 10; (Limit records)
• SELECT * FROM locations LIMIT 4,5; (Using LIMIT - Skip & Limit records)
• SELECT * FROM locations LIMIT 5 OFFSET 4; (Using LIMIT & OFFSET - Skip & Limit records)
www.inforepos.com
DQL
SQLite SELECT Query
• WHERE is a powerful filter, a WHERE clause can let you take exactly the piece of
the data you want. It sets the conditions for the SELECT, and the query will
return only those rows that match the conditions.
• WHERE clause with operators (Arithmetic, Boolean & Comparision)
• SELECT * FROM locations WHERE country_id='CA';
The following operators can be used with WHERE clause:
• operator description
• = Equal
• <> Not equal*
• > Greater than
• < Less than
• >= Greater than or equal
• <= Less than or equal
• SELECT * FROM agents WHERE commission<.15;
www.inforepos.com
DQL
SQLite SELECT Query
• WHERE clause with keywords
• DISTINCT
• AND and OR
• ORDER BY column_name(s) ACS | DESC
• GROUP BY
• GROUO BY and ORDER BY
• GROUO BY column_name HAVING
• GROUO BY column_name HAVING expression ORDER BY
• Please follow the notes below for detailed examples.
www.inforepos.com
DML
SQLite INSERT INTO
The INSERT command is used to create new rows in the specified table. The INSERT works on a
single table, and can both insert one row at a time or many rows at once using a SELECT
command. This statement is a part of the SQL Data Manipulation Language, DML.
• INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] VALUES
(value-list);
• INSERT INTO sensor_list (sensor_id, sensor_name, sensor_type, sensor_usage) VALUES
(‘TMP01’, ‘LM35’, ‘Temperature’, ‘Industrial’);
• INSERT INTO sensor_list (sensor_id, sensor_name, sensor_type) VALUES (‘TMP02’, ‘DHT11’,
‘Temperature’);
• INSERT INTO sensor_list VALUES (‘TMP03’, ‘DHT22’, ‘Temperature’, ‘Regular’);
• INSERT INTO sensor_list (sensor_id, sensor_name) VALUES (‘TMP005’, ‘LM335’);
• INSERT OR REPLACE INTO sensor_list (sensor_id, sensor_name, sensor_type, sensor_usage)
VALUES (‘TMP01’, ‘LM35’, ‘Temperature’, ‘Industrial/Regular’);
www.inforepos.com
DML
SQLite UPDATE
The UPDATE command is used to change the existing values to one or more columns of existing rows in a table. This
command can update more than one rows at a time, but all of the rows must be part of the same table.
• UPDATE table_name SET column_name=new_value [, ...] WHERE expression
• UPDATE sensor_list SET sensor_usage='Industrial/Regular' WHERE sensor_usage='Regular';
• UPDATE sensor_list SET sensor_name=(SELECT sensor_name FROM sensor_master WHERE sensor_id =
sensor_list_id);
• Eg. UPDATE sensor_list SET sensor_name=(
SELECT sensor_master.sensor_name
FROM sensor_master
WHERE sensor_list.sensor_list_id=sensor_master.sensor_id),
type_usage=(
SELECT sensor_master.sensor_type || sensor_list.sensor_usage
FROM sensor_master
WHERE sensor_list.sensor_list_id=sensor_master.sensor_id);
www.inforepos.com
DML
SQLite DELETE
• The DELETE command is used to delete or remove one or more rows from a
single table. When deleting all rows from the table this will not delete the
structure of the table, it will remain same only the records are deleted. To
delete a table from the database the DROP command is used.
• DELETE FROM [database-name .] table-name [WHERE expr]
• DELETE FROM sensor_list WHERE sensor_id=‘DHT11’;
• DELETE FROM sensor_test;
www.inforepos.com
Correct MIX … Current GEN
Python
PHP
JULIA
R
Web / Mobile
Programming
SQLite Perfect
Programming
THANK YOU
For All Queries : info@inforepos.com
Proven Database for
IIOT Applications
SQLite
Learn the Music of Database
IR SQLite Session #1

Más contenido relacionado

La actualidad más candente

Understanding Query Execution
Understanding Query ExecutionUnderstanding Query Execution
Understanding Query Execution
webhostingguy
 
Java class 8
Java class 8Java class 8
Java class 8
Edureka!
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for Developers
Jonathan Levin
 

La actualidad más candente (19)

Understanding Query Execution
Understanding Query ExecutionUnderstanding Query Execution
Understanding Query Execution
 
Java class 8
Java class 8Java class 8
Java class 8
 
Oracle training in hyderabad
Oracle training in hyderabadOracle training in hyderabad
Oracle training in hyderabad
 
Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New Features
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
plsql Les08
plsql Les08 plsql Les08
plsql Les08
 
Solr workshop
Solr workshopSolr workshop
Solr workshop
 
Brief introduction of Slick
Brief introduction of SlickBrief introduction of Slick
Brief introduction of Slick
 
Apache Solr + ajax solr
Apache Solr + ajax solrApache Solr + ajax solr
Apache Solr + ajax solr
 
Mentor Your Indexes
Mentor Your IndexesMentor Your Indexes
Mentor Your Indexes
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15
 
Mastering solr
Mastering solrMastering solr
Mastering solr
 
MySQL for beginners
MySQL for beginnersMySQL for beginners
MySQL for beginners
 
8. sql
8. sql8. sql
8. sql
 
plsql Les09
 plsql Les09 plsql Les09
plsql Les09
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for Developers
 
MYSQL
MYSQLMYSQL
MYSQL
 

Similar a IR SQLite Session #1

SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 
Less07 schema
Less07 schemaLess07 schema
Less07 schema
Imran Ali
 

Similar a IR SQLite Session #1 (20)

Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
 
Less07 schema
Less07 schemaLess07 schema
Less07 schema
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
 
Dbms &amp; oracle
Dbms &amp; oracleDbms &amp; oracle
Dbms &amp; oracle
 
MS SQL Server
MS SQL ServerMS SQL Server
MS SQL Server
 
Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
 
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ISql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices I
 
Aioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_features
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
SQL_NOTES.pdf
SQL_NOTES.pdfSQL_NOTES.pdf
SQL_NOTES.pdf
 
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle Database 12c  New Features for Developers and DBAs - OTN TOUR LA 2015Oracle Database 12c  New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
2..basic queries.pptx
2..basic queries.pptx2..basic queries.pptx
2..basic queries.pptx
 
SQL
SQLSQL
SQL
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

IR SQLite Session #1

  • 1. Proven Database for IIOT Applications SQLite Learn the Music of Database
  • 3. www.inforepos.com Agenda • Install & Configuring SQLite • DOT (.) Commands • Accessing Database • Basics of SQLite • Data Types • Operators • DQL (SELECT) • DML (INSERT, UPDATE, DELETE)
  • 4. www.inforepos.com Install /Configure SQLite • Unzip both the folders “sqlite-dll-win64-x64-3170000.zip” & “sqlite-tools- win32-x86-3170000.zip”. Merge all files and place them in one folder, say “C:sqlite3” • Add PATH parameter in system environment variables “C:sqlite3” • Open command prompt and go to “C:sqlite3” run sqlite3.exe There are two types of command interpreters in SQLite – • Free-form SQL statement • Recognized by SQLite program and expects SQL native words at the start of the statement • Dot-form statement • Identified by SQLite command-line program (sqlite3.exe) and starts with dot-command
  • 5. www.inforepos.com SQLite DOT(.) Commands • A dot-command must begin with the "." at the left margin with no preceding whitespace. • The dot-command must be entirely contained on a single input line. • A dot-command cannot occur in the middle of an ordinary SQL statement. In other words, a dot-command cannot occur at a continuation prompt. • Dot-commands do not recognize comments. • Eg. • .open • .tables • .output • .schema …. many
  • 6. www.inforepos.com Accessing Database OPEN, ATTACH, DETACH database • ATTACH [DATABASE] filename AS database_name; • sqlite3>sqlite3 sensorsdb.db • sqlite3> .database seq name file --- --------------- ------------------------ 0 main D:sqlite3sensorsdb.db
  • 7. www.inforepos.com Accessing Database OPEN, ATTACH, DETACH database • ATTACH customerdb AS custdb; • ATTACH DATABASE 'smartihomedb.db' as 'ihomedb'; • ATTACH DATABASE 'smartihealthdb.db' as 'ihealthdb'; • sqlite> .database seq name file --- --------------- ------------------------ 0 main D:/sqlite3/sensorsdb.db 2 custdb D:/sqlite3/customerdb.db 3 ihomedb D:/sqlite3/smartihomedb.db 4 ihealthdb D:/sqlite3/smartihealthdb.db
  • 8. www.inforepos.com OPEN, ATTACH, DETACH database • DETACH DATABASE 'Alias-Name'; • sqlite3> detach DATABASE sensorsdb; • sqlite3> .database • .open ?FILENAME? • sqlite3> .open D:/sqlite3/smartihomedb.db • sqlite3> .databases seq name file --- --------------- ------------------------------------ 0 main D:/sqlite3/smartihomedb.db
  • 9. www.inforepos.com SQLite Data Types • A data type specifies a particular type of data, such as integer, floating-point, Boolean etc. • A data type also specifies the possible values for that type, the operations that can be performed on that type and the way the values of that type are stored. NULL The value is a NULL value. INTEGER The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value. REAL The value is a floating point value, stored as an 8-byte IEEE floating point number. TEXT The value is a text string, stored using the database encoding (UTF-8, UTF- 16BE or UTF-16LE) BLOB The value is a blob of data, stored exactly as it was input.
  • 10. www.inforepos.com SQLite Data Types – Type Affinity Examples Example Type names From The CREATE TABLE Statement or CAST Expression Resulting Affinity Rule Used To Determine Affinity INT INTEGER TINYINT SMALLINT MEDIUMINT BIGINT UNSIGNED BIG INT INT2 INT8 INTEGER 1 CHARACTER(20) VARCHAR(255) VARYING CHARACTER(255) NCHAR(55) NATIVE CHARACTER(70) NVARCHAR(100) TEXT CLOB TEXT 2 BLOB no datatype specified NONE 3 REAL DOUBLE DOUBLE PRECISION FLOAT REAL 4 NUMERIC DECIMAL(10,5) BOOLEAN DATE | DATETIME NUMERIC 5
  • 11. www.inforepos.com SQLite Operators • Arithmetic Operators • Comparison Operators • Boolean Operators • LIKE Operator • Between Operator • IN and NOT IN Operators • EXISTS Operator
  • 12. www.inforepos.com SQLite Operators : Highest to Lowest precedence • || • * / % • + - • << >> & | • < <= > >= • = == != <> IS IS NOT IN LIKE GLOB MATCH REGEXP • AND • OR • Supported unary prefix operators are these: - + ~ NOT
  • 13. www.inforepos.com DQL SQLite SELECT Query • The SELECT statement is used to make a simple query from a database or a complicated query against some criteria. A SELECT statement does not make any changes to the database / database objects. • A query or SELECT statement is a command which gives instructions to a database to produce certain information(s) from the table in its memory. The SELECT command starts with the keyword SELECT. SELECT [ALL | DISTINCT] result [FROM table-list] [WHERE expr] [GROUP BY expr-list] [HAVING expr] [compound-op select]* [ORDER BY sort-expr-list] [LIMIT integer [(OFFSET|,) integer]]
  • 14. www.inforepos.com DQL SQLite SELECT Query • Parameters Clause Operation perform Input Value WHERE Used to restrict Expression or condition DISTINCT Used to restrict List of columns FROM Joins List of tables GROUP BY Used to restrict List of columns ORDER BY List of columns HAVING Used to restrict Expression or condition LIMIT Used to restrict Integer value OFFSET Used to restrict Integer value
  • 15. www.inforepos.com DQL SQLite SELECT Query Basic Arithmetic Operations without any Table: • SELECT 6+15; • SELECT 5*15; • SELECT 5+2-3*4/6; SELECT Operations Using Tables: • SELECT * FROM sensor_list; • SELECT street_address, city FROM locations; (Select required columns) • SELECT region_name AS "Name of the Region" FROM regions; (Renaming column names) • SELECT r.region_name FROM regions r; (Select using alias) • SELECT * FROM locations LIMIT 10; (Limit records) • SELECT * FROM locations LIMIT 4,5; (Using LIMIT - Skip & Limit records) • SELECT * FROM locations LIMIT 5 OFFSET 4; (Using LIMIT & OFFSET - Skip & Limit records)
  • 16. www.inforepos.com DQL SQLite SELECT Query • WHERE is a powerful filter, a WHERE clause can let you take exactly the piece of the data you want. It sets the conditions for the SELECT, and the query will return only those rows that match the conditions. • WHERE clause with operators (Arithmetic, Boolean & Comparision) • SELECT * FROM locations WHERE country_id='CA'; The following operators can be used with WHERE clause: • operator description • = Equal • <> Not equal* • > Greater than • < Less than • >= Greater than or equal • <= Less than or equal • SELECT * FROM agents WHERE commission<.15;
  • 17. www.inforepos.com DQL SQLite SELECT Query • WHERE clause with keywords • DISTINCT • AND and OR • ORDER BY column_name(s) ACS | DESC • GROUP BY • GROUO BY and ORDER BY • GROUO BY column_name HAVING • GROUO BY column_name HAVING expression ORDER BY • Please follow the notes below for detailed examples.
  • 18. www.inforepos.com DML SQLite INSERT INTO The INSERT command is used to create new rows in the specified table. The INSERT works on a single table, and can both insert one row at a time or many rows at once using a SELECT command. This statement is a part of the SQL Data Manipulation Language, DML. • INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] VALUES (value-list); • INSERT INTO sensor_list (sensor_id, sensor_name, sensor_type, sensor_usage) VALUES (‘TMP01’, ‘LM35’, ‘Temperature’, ‘Industrial’); • INSERT INTO sensor_list (sensor_id, sensor_name, sensor_type) VALUES (‘TMP02’, ‘DHT11’, ‘Temperature’); • INSERT INTO sensor_list VALUES (‘TMP03’, ‘DHT22’, ‘Temperature’, ‘Regular’); • INSERT INTO sensor_list (sensor_id, sensor_name) VALUES (‘TMP005’, ‘LM335’); • INSERT OR REPLACE INTO sensor_list (sensor_id, sensor_name, sensor_type, sensor_usage) VALUES (‘TMP01’, ‘LM35’, ‘Temperature’, ‘Industrial/Regular’);
  • 19. www.inforepos.com DML SQLite UPDATE The UPDATE command is used to change the existing values to one or more columns of existing rows in a table. This command can update more than one rows at a time, but all of the rows must be part of the same table. • UPDATE table_name SET column_name=new_value [, ...] WHERE expression • UPDATE sensor_list SET sensor_usage='Industrial/Regular' WHERE sensor_usage='Regular'; • UPDATE sensor_list SET sensor_name=(SELECT sensor_name FROM sensor_master WHERE sensor_id = sensor_list_id); • Eg. UPDATE sensor_list SET sensor_name=( SELECT sensor_master.sensor_name FROM sensor_master WHERE sensor_list.sensor_list_id=sensor_master.sensor_id), type_usage=( SELECT sensor_master.sensor_type || sensor_list.sensor_usage FROM sensor_master WHERE sensor_list.sensor_list_id=sensor_master.sensor_id);
  • 20. www.inforepos.com DML SQLite DELETE • The DELETE command is used to delete or remove one or more rows from a single table. When deleting all rows from the table this will not delete the structure of the table, it will remain same only the records are deleted. To delete a table from the database the DROP command is used. • DELETE FROM [database-name .] table-name [WHERE expr] • DELETE FROM sensor_list WHERE sensor_id=‘DHT11’; • DELETE FROM sensor_test;
  • 21. www.inforepos.com Correct MIX … Current GEN Python PHP JULIA R Web / Mobile Programming SQLite Perfect Programming
  • 22. THANK YOU For All Queries : info@inforepos.com
  • 23. Proven Database for IIOT Applications SQLite Learn the Music of Database