click below
click below
Normal Size Small Size show me how
Fundata
| Term | Definition |
|---|---|
| FUNDAMENTALS IN DATABASE SYSTEM DATA DEFINITION LANGUAGE (DDL) | these commands are used to define and manage the structure of your database and tables. |
| CREATE DATABASE | this command creates a new database |
| CREATE DATABASE database_name; | Syntax for creating database |
| To create a database named PREMIERE | CREATE DATABASE PREMIERE; |
| USE | this command activates a database, making it the default for all subsequent commands in the session. You must run this at the start of every session |
| USE database_name; | Syntax of using a database |
| USE PREMIER; | To activate the PREMIERE database |
| CREATE TABLE | this command describes the layout of a new table, including its columns, data types, and constraints like the primary key. |
| Syntax of creating a table | SQL CREATE TABLE table_name ( column1_name data_type [CONSTRAINT], column2_name data_type [CONSTRAINT], ... PRIMARY KEY (primary_key_column) ); |
| To create the REP table: | CREATE TABLE REP ( REP_NUM CHAR(2) PRIMARY KEY, LAST_NAME CHAR(15), FIRST_NAME CHAR(15), STREET CHAR(15), CITY CHAR(15), STATE CHAR(2), ZIP CHAR(5), COMMISSION DECIMAL(7,2), RATE DECIMAL(3,2) ); |
| DROP TABLE | this command permanently deletes an entire table, including all the data within it. |
| DROP TABLE table_name; | Syntax of deleting a table |
| Data Manipulation Language (DML) | these commands are used to add, modify, and delete data within tables |
| INSERT INTO | this command adds a new row of data to a table. Character values must be enclosed in single quotes. |
| Syntax (all columns) | INSERT INTO table_name VALUES (value1, value2, ...); |
| To add the first sales rep to the REP table | INSERT INTO REP VALUES ('20', ‘Kaiser’, ‘Valerie’, ‘624 Randall’, ‘Grove’, ‘FL’, 33321, 20542.50, 0.05); |
| Syntax (specific columns, for Nulls) | INSERT INTO table_name (column1, column2) VALUES (value1, value2); |
| To add sales rep with only their number and name, leaving other fields NULL: | INSERT INTO REP (REP_NUM, LAST_NAME, FIRST_NAME) VALUES (85, ‘Webb’, ‘Tina’); |