Friday, October 23, 2009

SQL server


SQL (Structured Query Language) server is a database program that can accommodate the data to be stored to support programs such as Delphi, java, visual basic or the other.
In general, SQL consists of two languages, namely Data Definition Language (DDL) and Data Manipulation Language (DML). DML is used to manipulate existing data in a table. Common commands are:
  1. SELECT to display the data.
  2. INSERT to add new data. 
  3. UPDATE to change the existing data.
  4. DELETE to delete the data. 
SELECT is the most common commands used in SQL, so the query term is sometimes attributed to the SELECT command. SELECT is used to display data from one or more tables, usually in the same database. In general, the SELECT command has a complete form:

  • SELECT [nama_tabel|alias.]nama_field1 [AS alias1] [, nama_field2, ...] FROM nama_tabel1 [AS alias1] [INNER|LEFT|RIGHT JOIN tabel2 ON kondisi_penghubung] [, nama_tabel3 [AS alias3], ...] [WHERE kondisi] [ORDER BY nama_field1 [ASC|DESC][, nama_field2 [ASC|DESC], ...]] [GROUP BY nama_field1[, nama_field2, ...]] [HAVING kondisi_aggregat]
Aggregate functions

Some have SMBD aggregate functions, namely the specific functions that involve a group of data (aggregate). In general, aggregate functions are:
SUM to calculate the total nominal data
COUNT to count the number of times the data
AVG to calculate the average group data
MAX and MIN to get the maximum value / minimum of a group of data.
Aggregate function used in the SELECT. Requirements for aggregate functions are placed in the HAVING, not WHERE.

Implementation of DDL and DML is different for each database management system (SMBD).
CREATE is used to create database objects and database. SQL is commonly used are:

CREATE DATABASE nama_basis_data

CREATE DATABASE to create a new database.

CREATE TABLE nama_tabel

CREATE TABLE create a new table on the basis of current data. In general, this command has the form

CREATE TABLE [nama_tabel]
(
nama_field1 tipe_data [constraints] [,
nama_field2 tipe_data,
...]
)

or

CREATE TABLE [nama_tabel]
(
nama_field1 tipe_data [,
nama_field2 tipe_data,
...]
[CONSTRAINT nama_field constraints]
)

with:

nama_field is the name of the column (field) which will be made. Some database management systems allow the use of spaces and characters in the name column nonhuruf.

depending on the implementation tipe_data database management system. For example, in MySQL, can be a data type VARCHAR, TEXT, BLOB, ENUM, and so on.

constraints are constraints that are given for each column. This also depends on the implementation of database management systems, such as NOT NULL, UNIQUE, and so on. This can be used to define the primary key (primary key) and foreign keys (foreign keys).

One table may not have a primary key at all, but it is advisable to define at least one column as primary key.

Example:

CREATE TABLE users
(
username VARCHAR (30) CONSTRAINT PRIMARY KEY,
passwd VARCHAR (20) NOT NULL,
tanggal_lahir DATETIME
);

No comments:

Post a Comment

 
THANK YOU FOR VISITING