Matakuliah : <<M0264>>/<<Sistem Manajemen Basis Data>> Tahun : <<2006>>

advertisement
Matakuliah
Tahun
Versi
: <<M0264>>/<<Sistem Manajemen Basis Data>>
: <<2006>>
: <<1/1>>
Materi Pendukung Pertemuan <<10>>
Transaksi pendukung pada SQL
1
SQL SELECT
• SELECT DISTINCT Table.Column {AS alias} , . .
.
• FROM Table/Query
• INNER JOIN Table/Query ON T1.ColA = T2.ColB
• WHERE (condition)
• GROUP BY Column
• HAVING (group condition)
• ORDER BY Table.Column
• { Union second select }
2
SQL Mnemonic
Someone
SELECT
From
FROM
Ireland
INNER JOIN
Will
WHERE
Grow
GROUP BY
Horseradish and
HAVING
Onions
ORDER BY
SQL is picky about
putting the
commands in the
proper sequence.
If you have to
memorize the
sequence, this
mnemonic may be
helpful.
3
SQL Data Definition
• Create Schema Authorization dbName
password
• Create Table TableName (Column Type, .
. .)
• Alter Table Table {Add, Column,
Constraint, Drop}
• Drop {Table Table | Index Index On table}
• Create Index IndexName ON Table
(Column {ASC|DESC})
4
Syntax Examples
CREATE TABLE Customer
(CustomerID INTEGER NOT NULL,
LastName CHAR (10),
more columns
);
ALTER TABLE Customer
DROP COLUMN ZipCode;
ALTER TABLE Customer
ADD COLUMN CellPhone CHAR(15);
5
Download