0% found this document useful (0 votes)
1 views12 pages

SQL Past Paper QuestionsMS1.1

This document provides a summary of MySQL commands categorized into database-level, table-level, and row-level operations. Key commands include creating and dropping databases and tables, inserting, updating, and deleting rows, as well as performing joins. It serves as a quick reference for essential MySQL syntax.

Uploaded by

hibajunaid107
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views12 pages

SQL Past Paper QuestionsMS1.1

This document provides a summary of MySQL commands categorized into database-level, table-level, and row-level operations. Key commands include creating and dropping databases and tables, inserting, updating, and deleting rows, as well as performing joins. It serves as a quick reference for essential MySQL syntax.

Uploaded by

hibajunaid107
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

SQL Assignment:

Summary of MySQL Commands Used in this Tutorial


-- Database-Level
DROP DATABASE databaseName -- Delete the database (irrecoverable!)
CREATE DATABASE databaseName -- Create a new database
SHOW DATABASES -- Show all the databases in this server
USE databaseName -- Set the default (current) database

-- Table-Level
CREATE TABLE tableName (
columnName columnType columnAttribute, ...
PRIMARY KEY(columnName),
FOREIGN KEY (columnName) REFERENCES tableName (columnName))

d
SHOW TABLES -- Show all the tables in the default database
DROP TABLE tableName, ...

hi
DESCRIBE tableName
ALTER TABLE tableName ADD columnDefinition
ALTER TABLE tableName DROP columnName
ALTER TABLE tableName ADD FOREIGN KEY (columnName) REFERENCES tableName
(columnName)
ALTER TABLE tableName
Za
DROP FOREIGN KEY constraintName

-- Row-Level
INSERT INTO tableName
VALUES (column1Value, column2Value,...) -- Insert on all Columns
a

INSERT INTO tableName


VALUES (column1Value, column2Value,...), ... -- Insert multiple rows
hr

INSERT INTO tableName (column1Name, ..., columnNName)


VALUES (column1Value, ..., columnNValue) -- Insert on selected Columns

DELETE FROM tableName WHERE criteria


Za

UPDATE tableName SET columnName = expr, ... WHERE criteria

SELECT * | column1Name AS alias1, ..., columnNName AS aliasN


FROM tableName
WHERE criteria
GROUP BY columnName
ORDER BY columnName ASC|DESC, ...

-- Join or Inner Join -- -- more than one table


SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name
WHERE criteria;
Page 1 of 12
d
hi
Za
a
hr
Za

Page 2 of 12
d
hi
Za
a
hr
Za

Page 3 of 12
d
hi
Za
a
hr
Za

Page 4 of 12
d
hi
Za
a
hr
Za

Page 5 of 12
d
hi
Za
a
hr
Za

Page 6 of 12
d
hi
Za
a
hr
Za

Page 7 of 12
d
hi
Za
a
hr
Za

Page 8 of 12
d
hi
Za
a
hr
Za

Page 9 of 12
d
hi
Za
a
hr
Za

Page 10 of 12
d
hi
Za
a
hr
Za

Page 11 of 12
d
hi
Za
a
hr
Za

Page 12 of 12

You might also like