DIFFERENT STRUCTURES IN DB Flashcards
DDL - Data Definition Language
Standard for commands that define the different structures in a database.
CREATE : Table, Size, Data Types
MODIFY : Alter Table - Name, Column, Data Type
DROP Table, View (can’t roll back)
REMOVE DB objects such as Tables, Indexes and User
CREATE
ALTER
DROP
DML - Data Manipulate Language Use to work with data ADD. MODIFY. UPDATE. QUERY 1. Select - Retrieve records from 1+ tables 2. Insert - Create 3. Update - Modify 4. Delete - Remove 5. Trigger - Instead, After ——————————— DCL - Data Control Language Use to control access to data Store in DB GRANT, REVOKE 1. Grant - Privilege to user 2. Revoke - Removes Privileges
NULL = ‘Unavailable’,’Unassigned’. Not same as 0 or blank.
DDL
Data Definition Language
Standard for commands that define the different structures in a database.
CREATE : Table, Size, Data Types
MODIFY : Alter Table - Name, Column, Data Type
DROP Table, View (can’t roll back)
REMOVE DB objects such as Tables, Indexes and User
DDL COMMANDS
- Create Command
Trigger, Drop, Create, Alter - Alter Table
Modify Table, Name, Column, Data Types - Drop Table
Table, View, can’t rollback
DML
Data Manipulation Language
Work with Data
Use to work with data
ADD. MODIFY. UPDATE. QUERY
DML Commands
1. Select Retrieves records from 1+ tables 2. Insert - Create 3. Update - Modify 4. Delete - Remove 5. Trigger - Instead, After
DCL
Data Control Language
Controls Access
Use to control access to data
Store in DB GRANT, REVOKE
DCL Commands
- Grant - Privilege to user.
2. Revoke - Removes Privileges
NULL
Unavailable
Unassigned
Not same as 0 or Blank
Examples of
DML Command Insert
Insert Into table-name(col 1, col 2)
Values(value 1, value 2);
————
Insert data from 1 table to another
Insert Into table-name
Select * from another-table : columns have to match
————-
Select from columns
Insert Into table-name (col 1, col 2)
Select (col 1, col 2) from another-table;
Examples of
DML Command Modify
Modify
UPDATE table-name
SET Col1 = value
WHERE condition;
Examples of
DML Command DELETE
DELETE
DELETE FROM table-name
WHERE condition;
Examples of
DML Command MERGE
MERGE - combine data from multiple tables
MERGE INTO Table 1 USING Table 2 ON (condition) WHEN MATCHED THEN UPDATE SET Col 1 = Value 1, Col 2 = Value 2 WHEN NOT MATCHED THEN INSERT (C1,C2) VALUES (V1,V2);