Cth:
CREATE menciptakan objek baru.
ALTER mengubah objek.
DROP menghapus objek.
DML (Data Manipulation Language)
DML adalah kelompok perintah yang berfungsi untuk
memanipulasi data, misalnya untuk pengambilan,
penyisipan, pengubahan dan penghapusan data.
Cth:
SELECT memilih data.
INSERT INTO menambah data.
UPDATE mengubah data.
DELETE menghapus data.
DCL (Data Control Language)
DCL adalah perintah SQL yang berhubungan dengan
pengaturan otoritas user dalam melakukan akses data.
Cth:
GRANT memberikan kendali pada pengaksesan data.
REVOKE mencabut kemampuan pengaksesan data.
TCL (Transaction Control Language)
TCL adalah perintah-perintah yang berfungsi untuk
mengendalikan pengeksekusian transaksi.
Cth:
COMMIT menyetujui rangkaian perintah yang
berhubungan erat yang telah berhasil dilakukan.
ROLLBACK membatalkan transaksi yang dilakukan
karena adanya kesalahan atau kegagalan pada salah satu
rangkaian perintah.
Pengendali Programatik
Perintah bahasa pemrograman yang berada di
level client side atau front end untuk
menampilkan data kedalam bentuk informasi
yang berguna bagi user.
Contoh:
CREATE DATABASE POLTEK
atau
CREATE DATABASE [BANK INDONESIA]
Mengaktifkan database:
USE [BANK INDONESIA]
SQL DROP DATABASE
DROP DATABASE <database_name>
Contoh:
DROP DATABASE POLTEK
atau
DROP DATABASE [BANK INDONESIA]
SQL CREATE TABLE
CREATE TABLE <table_name>
(column_name1 datatype,
column_name2 datatype, ...
column_nameN datatype);
SELECT column_name(s)
FROM table_name
Now we want to select only the persons with the first name equal to "Tove" AND
the last name equal to "Svendson“.
Now we want to select only the persons with the first name equal to "Tove" OR
the first name equal to "Ola“.
Now we want to select only the persons with the last name equal to "Svendson"
AND the first name equal to "Tove" OR to "Ola"
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause
specifies which record or records that should be updated. If you omit the
WHERE clause, all records will be updated!
UPDATE Persons
SET Address='Nissestien 67', City='Sandnes'
WHERE LastName='Tjessem' AND
FirstName='Jakob'
SQL UPDATE Warning
UPDATE Persons
SET Address='Nissestien 67',
City='Sandnes'
Menghapus data
Digunakan untuk menghapus record pada suatu tabel.
Terdiri dari:
Concatenation (Rangkaian)
Mathematical Calculations (Perhitungan
matematika)
Concatenation (Rangkaian)
SELECT ColumnName + ‘ ‘ +
ColumnName + ‘ ‘
FROM TableName
SELECT FirstName + ' ' + LastName
FROM Employees
Note that concatenation only
works with strings. To
concatenate other data types,
you must first convert them to
strings
Mathematical Calculations
(Perhitungan matematika)
If the cost of freight is greater than or equal to $500.00, it will now be taxed by
11%. Create a report that shows the order id, freight cost, freight cost with this tax
for all orders of $500 or more.
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern
Now we want to select the persons living in a city that starts with "s" from the
table above
The "%" sign can be used to define wildcards (missing letters in the pattern) both before
and after the pattern
Next, we want to select the persons living in a city that ends with an
"s" from the "Persons" table
SELECT column_name(s)
FROM table_name
WHERE column_name IN
(value1,value2,...)
Now we want to select the persons with a last name equal to "Hansen" or "Pettersen" from
the table above
SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2
SEKIAN