SQL Notes-Week - 1
SQL Notes-Week - 1
Data:
Data is a collection of a distinct small unit of information. It can be used in a variety of forms like
text, numbers, media, bytes, etc. it can be stored in pieces of paper or electronic memory, etc.
Database:
A database is an organized collection of data, so that it can be easily accessed and managed.
You can organize data into tables, rows, columns, and index it to make it easier to find relevant information.
Types of Databases:
• Relational Database - SQL
• Non-Relational Database – NO SQL
Types of DBMS:
Syntax
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
Syntax
DROP TABLE table_name;
Syntax
TRUNCATE TABLE table_name;
SQL Constraints: SQL constraints are used to specify rules for data in a
table.
Example:
lastname varchar(20),
Age int ,
);
Difference Between DROP TRUNCATE and DELETE
Syntax
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
UPDATE Statement
The UPDATE statement is used to modify the existing records in a table.
Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
DELETE Statement
The DELETE statement is used to delete existing records in a table.
Syntax
DELETE FROM table_name WHERE condition;
SELECT Statement
The SELECT statement is used to select data from a database.
Syntax
SELECT column1, column2, ...
FROM table_name;
To get all data,
SELECT * FROM tablename;