Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Sq lite
1. PSG COLLEGE OF TECHNOLOGY
Open Source DBMS Lab Report
R.H.S.BHARADWAJA
13Z245
BE-CSE-G1
2. Introduction to SQLite
SQLite is a relational database management system contained in a
C programming library.
In contrast to other database management systems, SQLite is not
implemented as a separate process that a client program running
in another process accesses. Rather, it is part of the using
program.
SQLite is ACID-compliant and implements most of the SQL
standard, using a dynamically and weakly typed SQL syntax that
does not guarantee the domain integrity.[5]
SQLite is a popular choice as embedded database for local/client
storage in application software such as web browsers.
It is arguably the most widely deployed database engine, as it is
used today by several widespread browsers, operating systems,
and embedded systems, among others.[6]
SQLite has bindings to
many programming languages.
HISTORY
D. Richard Hipp designed SQLite in the spring of 2000 while
working for General Dynamics on contract with the United States
NavY.
Hipp was designing software used aboard guided missile
destroyers, which were originally based on HP-UX with an IBM
Informix database back-end.
The design goals of SQLite were to allow the program to be
operated without installing a database management system or
requiring a database administrator.
Hipp based the syntax and semantics on PostgreSQL 6.5
documentation.
3. In August 2000, version 1.0 of SQLite was released, with storage
based on gdbm (GNU Database Manager). SQLite 2.0 replaced
gdbm with a custom B-tree implementation, adding support for
transactions. SQLite 3.0, was later developed by america online
adding manifest typing feature.
DESIGN
Unlike client–server database management systems, the SQLite
engine has no standalone processes with which the application
program communicates.
Instead, the SQLite library is linked in and thus becomes an
integral part of the application program.
The library can also be called dynamically.
The application program uses SQLite's functionality through
simple function calls, which reduce latency in database access:
function calls within a single process are more efficient than inter-
process communication.
SQLite stores the entire database (definitions, tables, indices, and
the data itself) as a single cross-platform file on a host machine.
It implements this simple design by locking the entire database
file during writing.
SQLite read operations can be multitasked, though writes can
only be performed sequentially.
SQLite uses PostgreSQL as a reference platform. “What would
PostgreSQL do”, is used to make sense of the SQL standard.
One major deviation is that, with the exception of primary keys,
SQLite does not enforce type checking; the type of a value is
dynamic and not strictly constrained by the schema.
4. SYNTAX AND PURPOSE
SQLite Statements
All the SQLite statements start with any of the keywords like SELECT,
INSERT, UPDATE, DELETE, ALTER, DROP, etc., and all the statements
end with a semicolon (;).
SQLite ANALYZE Statement:
SYNTAX:
ANALYZE database_name.table_name;
OR
ANALYZE
OR
ANALYZE database_name
The ANALYZE command gathers statistics about tables and indices and
stores the collected information in internal tables of the database.
PURPOSE AND QUERY:
If no arguments are given, all attached databases are analyzed. If a
database name is given as the argument, then all tables and indices in
that one database are analyzed. If the argument is a table name, then
only that table and the indices associated with that table are analyzed.
If the argument is an index name, then only that one index is analyzed.
5. SQLite CREATETABLE Statement:
CREATE TABLE table_name(column1datatype,column2datatype,.......columnndatatype
PRIMARY KEY( one or more columns ));
Output:
PURPOSE AND QUERY:
The "CREATE TABLE" command is used to create a new table in an SQLite
database. A CREATE TABLE command specifies the following attributes of the
new table:
The name of the new table.
The database in which the new table is created. Tables may be created
in the main database, the temp database, or in any attached database.
The name of each column in the table.
The declared type of each column in the table.
A default value or expression for each column in the table.
Optionally, a PRIMARY KEY for the table. Both single column and
composite (multiple column) primary keys are supported.
6. SQLite ALTER TABLE Statement:
ALTER TABLE table_name ADDCOLUMN column_def...;
OUTPUT:
PURPOSE AND QUERY:
The ADD COLUMN syntax is used to add a new column to an existing
table. The new column is always appended to the end of the list of
existing columns. The column-def rule defines the characteristics of the
new column. The new column may take any of the forms permissible in
a CREATE TABLE statement, with the following restrictions:
The column may not have a PRIMARY KEY or UNIQUE constraint.
The column may not have a default value of CURRENT_TIME,
CURRENT_DATE, CURRENT_TIMESTAMP, or an expression in
parentheses.
If a NOT NULL constraint is specified, then the column must have
a default value other than NULL.
7. SQLite DROP TABLE Statement:
Syntax:
Basic syntax of DROP TABLE statement is as follows. You can optionally
specify database name along with table name as follows:
DROP TABLE database_name.table_name;
Example:
Let us first verify COMPANY table and then we would delete it from the database.
sqlite>.tables
COMPANY test.COMPANY
This means COMPANY table is available in the database, so let us drop it as follows:
sqlite>DROPTABLECOMPANY;
sqlite>
Now, if you would try .TABLES command then you will not find COMPANY table anymore:
sqlite>.tables
sqlite>
PURPOSE AND QUERY:
The DROP TABLE statement removes a table added with the
CREATE TABLE statement. The name specified is the table name.
The dropped table is completely removed from the database
schema and the disk file. The table can not be recovered.
All indices and triggers associated with the table are also deleted.
8. SQLite INSERT INTO Statement:
Syntax:
INSERT INTO table_name VALUES ( value1, value2....valueN);
OUTPUT:
PURPOSE AND QUERY:
When inserting records into a table using the SQLite INSERT
statement, you must provide a value for every NOT NULL column.
You can omit a column from the SQLite INSERT statement if the
column allows NULL values.
9. SQLite SELECT Statement:
SYNTAX:
SELECT * from table_name
Or
SELECT column1, column2....columnN FROM table_name;
OUTPUT:
PURPOSE AND QUERY:
The SQLite SELECT statement is used to retrieve records from one
or more tables in SQLite.
This SQLite SELECT example joins two tables together to gives us a
result set that displays the employee_id, last_name, and title
fields where the employee_id value matches in both the
employees and positions table. The results are sorted by title in
ascending order.
10. SQLite VACUUM Statement:
The VACUUM command cleans the main database by copying its
contents to a temporary database file and reloading the original
database file from the copy.
This eliminates free pages, aligns table data to be contiguous, and
otherwise cleans up the database file structure.
The VACUUM command may change the ROWID of entries in tables
that do not have an explicit INTEGER PRIMARY KEY.
The VACUUM command only works on the main database. It is not
possible to VACUUM an attached database file.
The VACUUM command will fail if there is an active transaction.
The VACUUM command is a no-op for in-memory databases.
As the VACUUM command rebuilds the database file from scratch,
VACUUM can also be used to modify many database-specific
configuration parameters.
Manual VACUUM
Following is simple syntax to issue a VACUUM command for the whole database from
command prompt:
$sqlite3 database_name "VACUUM;"
You can run VACUUM from SQLite prompt as well as follows:
sqlite> VACUUM;
You can also run VACUUM on a particular table as follows:
sqlite> VACUUM table_name;
11. BUILT IN FUNCTIONS IN SQLITE
A function that is available through a simple reference and specification
of arguments in a given higher-level programming language. Also
known as built-in procedure; intrinsic procedure; standard function.
SQLite has many built-in functions for performing processing on string or numeric
data. Following is the list of few useful SQLite built-in functions and all are case in-
sensitivewhich means you can use these functions either in lower-case form or in
upper-case or in mixed form. For more details, you can check official
documentation for SQLite:
S.N. Function & Description
1
SQLite COUNT Function
The SQLite COUNT aggregate function is used to count the number of rows
in a database table.
2
SQLite MAX Function
The SQLite MAX aggregate function allows us to select the highest
(maximum) value for a certain column.
3
SQLite MIN Function
The SQLite MIN aggregate function allows us to select the lowest (minimum)
value for a certain column.
4
SQLite SUM Function
The SQLite SUM aggregate function allows selecting the total for a numeric
column.
5
SQLite UPPER Function
The SQLite UPPER function converts a string into upper-case letters.
12. S.N. Function & Description
6
SQLite LOWER Function
The SQLite LOWER function converts a string into lower-case letters.
7
SQLite LENGTH Function
The SQLite LENGTH function returns the length of a string.
SQLite MAX Function
SYNTAX:
SELECT max( expression ) FROM tables WHERE conditions;
Example - With Single Expression
Let's look at some SQLite max function examples and explore how to use the max
function in SQLite.
For example, you might wish to know how the maximum salary of all employees.
SELECT max(salary) AS "HighestSalary"
FROMemployees;
In this max function example, we've aliased the max(salary) expression as
"HighestSalary".
13. SQLite UPPER Function:
The SQLite UPPER function converts a string into upper-caseletters.
The SQLite upper function converts all characters in the specified string
to uppercase. If there are characters in the string that are not letters,
they are unaffected by this function
SYNTAX:
“upper( string )”
Example:
Let's look at some SQLite upper function examples and explore how to
use the upper function in SQLite.
For example:
sqlite> SELECT upper('TechOnTheNet.com');
Result: 'TECHONTHENET.COM'
sqlite> SELECT upper('Techonthenet.com is as easy as 123.');
Result: 'TECHONTHENET.COM IS AS EASY AS 123.'
sqlite> SELECT upper(' Totn ');
Result: ' TOTN '
14. APPLICATIONS
A few of the better-known users of SQLite are shown below in
alphabetical order. There is no complete list of projects and companies
that use SQLite. SQLite is in the public domain and so many groups use
SQLite in their projects without ever telling us.
Adobe uses SQLite as the application file
format for their Photoshop Lightroom
product. SQLite is also a standard part of
the Adobe Integrated Runtime (AIR). It is
reported that Acrobat Reader also uses
SQLite.
Apple uses SQLite for many functions
within Mac OS X, including Apple Mail,
Safari, and in Aperture. Apple uses SQLite
in the iPhone and in the iPod touch and in
iTunes software.
The increasingly popular Dropbox file
archiving and synchronization service is
reported to use SQLite as the primary data
store on the client side.
15. Itis known that Google uses SQLite in their
Desktop for Mac, in Google Gears, in the Android
cell-phone operating system, and in the Chrome
Web Browser. Peopleare suspicious that Google
uses SQLite for lots of other things that we do
not know about yet. Engineers at Google have
made extensive contributions to the full-text
search subsystemwithin SQLite.
McAfee uses SQLite in its antivirus programs.
Mentioned here and implied here.
Itcan be inferred fromtraffic on the SQLite
mailing list that at least one group within
Microsoftis using SQLite in the development of a
game program. No word yet if this game has
actually been released or if they are still using
SQLite.
There are multiple sightings of SQLite in the
Skypeclient for Mac OS X and Windows.