Section 2: SQL Theory Flashcards
4 Different types of programming
- Procedural (Imperative)
- Object-Oriented
- Declarative (outcome)
- Functional
4 Main components of Data SQL Syntax and purpose
- Data Definition Language (DDL) Creation of Data
- Data Manipulation Language (DML) Manipulation of Data
- Data Control Language (DCL) Assignment and removal of permission to use data
- Transaction Control Language (TCL) Saving and restoring changes to a database
What is DDL
- Data Definition Language
- A syntax not a language
- A set of statements that allow the user to define or modify data structures and objects, such as tables.
DDL Purpose
Used for creating entire databases and database objects as tables
Create Statement
Syntax used for creating entire databases and database objects as tables
Alter Statement (3 uses)
Syntax used when altering existing objects 1. Add 2. Remove 3. Rename one of the columns in the table
Drop Statement
Syntax used to delete entire table
Rename Statement
Syntax used to rename a table
Truncate Statement
Syntax used to remove data in a table but keep the code/formula
DDL 5 Syntaxes
Data Definition Language
- Create
- Alter
- Drop
- Rename
- Truncate
Keyword
- Reserved words
- Keywords in SQL cannot be variable names.
- Keywords that cannot be used when naming objects
Excel formula names
DML
Data manipulation Language
Select Statement
Syntax that will select information in a table.
- Useful in getting micro view of large data
u
Insert Statement
Syntax used to insert data into the tables
Update Statement
Syntax used to update information in a table
Delete Statement
Syntax similar to truncate that allows you to specify precisely what you would like to be removed
Truncate V. Delete
- Truncate removes all data
2. delete removes specific data in a table
DML 4 main statements and syntax
- Select… From…
- Insert… Into… Values
- Update… Set… Where….
- Delete… from… Where
DCL
Data control Language
which allows to manage the rights users have in a database
1. Grant
2. Revoke
Grant Statement
Gives (grants) certain permissions to users.
Database Administrators
People who have complete rights to a database, they can grant access to users or revoke it
Revoke Statements
Used to revoke permissions and privileges of database users
TCL
Transaction Control Language
Commit Statement
- Save changes made
- Relates to Insert, Delete, Update
- Will let other users have access to the modified version of the database
Rollback Clause
Allows to undo any changes made that do not wish to save permanently..
Rollback reverts to the last non-committed state