SQLite
SQLite
SQLite
--------
->SQLite is a light weight RDBMS (Relational DataBase Management Software)
->helps us in maintaining data in an organized, secure manner.
->we maintain the data in Databases (which is a collection of tables)
sqlite3.exe
eg:
---
.open mydb.sqlite
--------------------------------------------
datatypes in SQLite:
integer for saving numbers
real for saving decimal numbers
text for saving string
eg:
---
CREATE TABLE students
(roll integer,
name text,
m1 real,
m2 real,
per real);
eg:
--
.schema students
eg:
--
ALTER TABLE students
ADD COLUMN phone text;
eg:
---
DROP TABLE students;
===============================================
INSERT:
is used to insert / add a new row / record in the table.
syntax:
-------
INSERT INTO tablename
(colname, colname, colname)
VALUES(value1, 'value2', value3);
Rules:
->no. of values must match the no. of cols given
->the text values need to be written within ' '
eg:
---
INSERT INTO students
(roll, name, m1, m2)
VALUES (101, 'Siddharth', 89.5, 65.5);
=================================================
UPDATE:
-------
->is used to edit a row / record's value
syntax:
-------
UPDATE tablename
SET colname=newvalue , colname='newvalue'
WHERE condition;
Rules:
->WHERE is optional
->when we put WHERE, only some of the records get updated
->when we do not put WHERE, all of the records get updated
->text values to be written within ' '
eg:
---
Q1. add the m1 of roll no 102 by 3 marks
Query:
UPDATE students
SET m1=m1+3
WHERE roll=102;
=====================================================
DELETE:
-------
->is used to delete a row / record
syntax:
-------
DELETE FROM tablename
WHERE condition;
Rules:
->WHERE is optional
->when we put WHERE, only some of the records get deleted
->when we do not put WHERE, all of the records get deleted
->text values to be written within ' '
======================================================
SELECT:
-> records retrieval
syntax:
------
SELECT colname, colname, colname
FROM tablename
WHERE condition;
RUles:
->WHERE is optional
->if we put WHERE only some of the records will get retrieved
->if we do not put WHERE all of the records will get retrieved
!Q. display the records of the students who have scored per greater than 70
=====================================================