160 likes | 567 Views
Structured query language. This is a presentation by JOSEPH ESTRada on the beauty of Structured Query Language. So, what is SQL you ask?. Language designed for the retrieval and management of data. Standard Data Manipulation Language(DML).
E N D
Structured query language • This is a presentation by JOSEPH ESTRada on the beauty of Structured Query Language
So, what is SQL you ask? • Language designed for the retrieval and management of data. • Standard Data Manipulation Language(DML). • Data definition language(DDL). Defines structure of the database.
MYSql language structure • Literal values (Strings, numbers, hexadecimal values, boolean values, bit-field values, null values) • database, table, index, column, and alias names • reserved words • user-defined variables • comments
literal values • string: character sequence in single or double quotes. optional “collate” clause used to specify collation. • numbers: sequence of digits. • hexadecimal values: Act as binary strings or 64-bit precision integers. • Boolean values: booleans. • bit-field values • null values
mysql language structure cont... • Identifiers: DB, table, index, column, and alias names. • reserved words: SELECT, UPDATE, DELETE, etc... (pg 570) • user-defined variables: SET @varr=value. allows shared data between statements. • comments: #, --, /* */
Data Definition statements • ALTER DATABASE: change characteristics of db. • ALTER TABLE: change table structure/schema. • CREATE DATABASE: creates new db. • CREATE TABLE: creates new table. • DROP DATABASE: removes a dB. • DROP TABLE: removes a table. • RENAME TABLE: changes table name.
Data manipulation statements (not complete) • DELETe: deletes tuples • insert: Insert tuples into a given table • select: Relational projection operator • update: Updates attribute/s
Aggregate functions • avg(column): AVg of a column • COUnt(column): number of rows w/o null value • MAX(column): highest value of a column. • MIN(column): Lowest value of a column. • SUM(column): Total sum of a column.
group by • Number of classes taught per instructor with GROUP by clause.
predicate • Classes under CS department with units 3 or greater.
count • Amount of courses taught by each department.
delete (DML) • delete all tuples.
DROP TABLE (DDL) • delete the table from the db.