4. • Databases can store very large
numbers of records efficiently (they
take up little space).
• It is very quick and easy to find
information.
• It is easy to add new data and to edit
or delete old data.
• Data sharing. Fast and efficient
collaboration between users.
• Data access and auditing. Controlled
access to databases.
7. SQL (Structured Query Language) is a standardized programming language
that's used to manage relational databases and perform various operations
on the data in them.
8. SQL is not a database system, but it is a query
language.
10. RDBMS
Relational Database Management System
An RDBMS is a type of database management system (DBMS)
that stores data in a row-based table structure which
connects related data elements.
Why RDBMS?
An RDBMS includes functions that maintain the security,
accuracy, integrity and consistency of the data.
Examples
Examples of the most popular RDBMS are MYSQL, Oracle,
IBM DB2, and Microsoft SQL Server database.
12. SQL CREATE DATABASE
The CREATE DATABASE statement is used to create a new SQL
database.
CREATE DATABASE
databasename;
13. SQL CREATE TABLE
The CREATE TABLE statement is used to create a new table in a
database.
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
The column parameters specify the names of the
columns of the table. The datatype parameter
specifies the type of data the column can hold
(e.g. varchar, integer, date, etc.).
14. SQL INSERT INTO
The INSERT INTO statement is used to insert new records in a table.
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
Specify both the column names and the values to
be inserted, when you are targeting only specific
ones.
INSERT INTO table_name
VALUES (value1, value2, value3, ...);
If you are adding values for all the columns of the
table, you do not need to specify the column
names in the SQL query
16. USING SQL SELECT
The SELECT statement is used to select data from a database. The
data returned is stored in a result table, called the result-set.
SELECT column1, column2, ...
FROM table_name;
Specify both the column names, when you are
targeting only specific ones.
SELECT * FROM table_name;
If you want to select all the fields available in the
table, use *
17. USING SQL SELECT DISTINCT
The SELECT DISTINCT statement is used to return only distinct
(different) values.
SELECT DISTINCT column1, column2, ...
FROM table_name;
Specify column names, when you are targeting
only specific ones.
SELECT DISTINCT * FROM table_name;
If you want to select all the fields available in the
table, use *
18. USING SQL WHERE
The WHERE clause is used to filter records.
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Specify column names, when you are targeting
only specific ones.
SELECT * FROM table_name WHERE
condition;
If you want to select all the fields available in the
table, use *
19. SQL UPDATE
The UPDATE statement is used to modify the existing records in a
table.
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Be careful when updating records in a table! Notice the WHERE clause in the UPDATE
statement. The WHERE clause specifies which record(s) that should be updated. If you omit
the WHERE clause, all records in the table will be updated!
20. SQL DELETE
The DELETE statement is used to delete existing records in a table.
DELETE FROM table_name WHERE condition;
Be careful when deleting records in a table! Notice the WHERE clause in the DELETE
statement. The WHERE clause specifies which record(s) should be deleted. If you omit the
WHERE clause, all records in the table will be deleted!
23. USING SQL AND operator
The AND operator displays a record if all the conditions separated by
AND are TRUE.
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 OR condition3 ...;
The AND operator is used to filter records based on more than one condition
24. USING SQL OR operator
The OR operator displays a record if any of the conditions separated
by OR is TRUE.
SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
The OR operator is used to filter records based on more than one condition
25. USING SQL NOT operator
The NOT operator displays a record if the condition(s) is NOT TRUE.
SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
The NOT operator is used to filter records when conditions turns out to be False!
27. SQL DROP TABLE
The DROP TABLE statement is used to drop an existing table in a
database.
DROP TABLE table_name;
Be careful before dropping a table. Deleting a table will result in loss of complete information
stored in the table!
29. SQL DROP DATABASE
The DROP DATABASE statement is used to drop an existing SQL
database.
DROP DATABASE databasename;
Be careful before dropping a database. Deleting a database will result in loss of complete
information stored in the database!
38. Full form of RDBMS
Relational Database Management System
39. CREATE TABLE StudentData(
regNo int,
StudentName varchar(255)
);
INSERT INTO StudentData VALUES (1234, "Abc");
UPDATE StudentData SET StudentName="Cde" WHERE regNo=1234;
SELECT * FROM StudentData;
What's the output?
40. CREATE TABLE StudentData(
regNo int,
StudentName varchar(255)
);
INSERT INTO StudentData VALUES (1234, "Abc");
UPDATE StudentData SET StudentName="Cde" WHERE regNo=1234;
SELECT * FROM StudentData;
Abc changes to Cde