Basic SQL Flashcards
Name 6 aggregate functions
COUNT() SUM() MAX() MIN() AVG() ROUND()
Whats the syntax for creating a primary key?
ALTER TABLE table ADD CONSTRAINT constraintName PRIMARY KEY (colName)
Whats the syntax for creating a foreign key?
ALTER TABLE table1 ADD CONSTRAINT constraintName FOREIGN KEY (foreignkey_table1_Name) REFERENCES table2 (foreignkey_table2_Name);
Whats the syntax for dropping a constraint?
ALTER TABLE tableName
DROP CONSTRAINT constraintName;
How do you get the current date?
SYSDATE
Whats the syntax for using the substr() function?
SUBSTR(string, startPosition, length)
Whats the syntax for using the concat() function?
CONCAT(str1, str2)
Whats the syntax for creating a table?
CREATE TABLE table_name (
column1 datatype,
column2 datatype
);
Whats the syntax for inserting a row into a table?
INSERT INTO table_name
VALUES (value1, value2);
Whats the syntax for deleting a row into a table?
DELETE FROM table_name WHERE condition;
Whats the syntax for updating a row(s) in table?
UPDATE table_name
SET column = value
WHERE condition;