Week 7 - SQL Part 1 Flashcards
What are the two categories that SQL functions fit into?
- Data definition language (DDL)
Includes SQL commands to create database objects such as tables, indexes, and views - Data manipulation language (DML)
Includes SQL commands to insert, update, delete and retrieve data within the database
What are the two main tasks to be completed when creating a new database?
The two main tasks are:
- Create database structure
- RDBMS creates the physical files that will hold the database
- differs from on RDBMS to another
- Usually includes authentication process
- Create tables that will hold the end-user data
What is authentication?
Authentication is the process through which the DBMS verifies that only registered users access the database created. Users should log on to the RDBMS using a user ID and a password created by the database administrator.
What is a schema?
A schema is Group of database objects such as tables and indexes that are related to each other
What are some SQL data types?
- Numeric: number, integer, smallint, decimal
- Character: char, varchar
- Date
What are the different types of SQL constraints?
- NOT NULL
Ensures that a column does not accept nulls - UNIQUE
Ensures that all values in a column are unique - DEFAULT
Assigns a value to an attribute when a new row is added to a table - CHECK
Validates data when an attribute value is entered
What are the different data manipulation commands in SQL?
The data manipulation commands in SQL are:
- INSERT: Adding table rows
- COMMIT: Saving table changes
- SELECT: Listing table rows
- UPDATE: Updating table rows
- ROLLBACK: Restoring table contents to state prior to changes
- DELETE: Deleting table rows
- INSERT + SELECT - Inserting table rows with a select subquery
How do you add a new table row into a table using SQL commands?
This is the structure of a command that inserts a new table:
INSERT INTO tablename VALUES (v1, V2,…);
What is the syntax for updating table rows?
Syntax for updating table rows:
UPDATE tablename
SET columnname = expression [, columnname = expression]
[WHERE conditionlist];
What is the syntax for deleting table rows?
Syntax for deleting table rows:
DELETE FROM tablename
[WHERE conditionlist]