SQL Flashcards
(19 cards)
DDL =
Data Definition Language like ALTER, DROP, CREATE
DCL =
Data Control Language like GRANT REVOKE.
List 5 SQL constraints:
NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY DEFAULT
Data types:
varchar2(255)
number(2, 5)
Date
Load data into table:
INSERT INTO tablename
VALUES (5, name, whatever);
When to use ‘’ and when to use “”
AS = “”
column name = ‘’
WHERE lastName > ‘k’
Use Boolean logic NOT and BETWEEN
WHERE NOT(‘Qty’ BETWEEN 3 AND 7);
Which is processed first, AND / OR?
AND before OR
WHERE State=’IL’ OR State=’CA’ AND Qty >8;
IN operator:
WHERE State IN (‘IL’, ‘NY’);
ROUND operator:
ROUND (ValueToBeRounded, decimal places)
How to select null?
WHERE ‘qty’ IS NULL;
Five aggregate functions
COUNT SUM MAX MIN AVG
Aggregate fictions can only be used where?
SELECT list and HAVING clause
DROP TABLE customers CASCADE CONSTRAINTS PURGE;
ALTER TABLE customers REBAME COLUMN customer_name to cname;
Remove all rows from a table
TRUNCATE TABLE mutable;
Get rid of column zip code
ALTER TABLE customers DROP COLUMN zip-code;
Update values in table
UPDATE myTable SET name=’kill’;
Delete a record
DELETE FROM myTable
WHERE name=’Jill’;
DML =
Data Manipulation Language like SELECT