Tag Archives: SQL tutorial

PL/SQL


PL/SQL stands for Programming Language / Structure Query Language. SQL is a standard language for accessing databases. SQL is used to manage data, to select, to update and to delete data against database. SQL usually used in Oracle, MS SQL, MySQL, SQL Server, Access, Sysbase, DB2 and other database systems.

Using SQL you can :
– query data
– insert data to the database
– update data to the database
– delete data to the database
– create database
– create table
– create view
– alter database
– alter table
– alter view
– give permission to the user to access the database

Here is some SQL tutorials :
SQL standart statement
select statement
select *field name*
from *table name*
where *condition*

insert statement
insert into *table name*
values (*value1*, *value2*, etc)

insert into *table name* (column1,column2, etc)
values (*value1*, *value2*, etc)

delete statement
delete *table name*

delete *table name*
where * column name * = *value*

ltrim dan rtrim
Contoh penggunaan ltrim :
– ltrim (‘melisa’,’m’) akan menghasilkan output elisa
– ltrim (‘melisa’,’imel’) akan menghasilkan output sa

Contoh penggunaan rtrim :
– rtrim(‘harian’,’na’) akan menghasikan output hari

Trunc
sysdate :03/07/2008
Contoh trunc(sysdate,’YY’) = 01/01/2008
trunc(sysdate,’MM’) = 01/07/2008
trunc(sysdate,’DD’) = 03/07/2008

Decode
Penggunaan decode seperti penggunaan if, hanya saja terdapat dalam select statement.
Contoh : decode(variable,’ice’,’dingin’,’tidak dingin’)
Artinya jika variable = ice, maka dingin. Jika variable ice maka tidak dingin.

Update Time
UPDATE database.table
SET start_date=TO_DATE(’11:20:00′,’hh:mi:ss’)
WHERE pk_id=100

PL/SQL is Oracle Corporation’s procedural extension language for SQL and the Oracle relational database. PL/SQL is one of three key programming languages embedded in the Oracle Database, along with SQL itself and Java.PL/SQL is available in Oracle Database (since version 7).

You can use some programming in PL/SQL.

Conditional Statement
if x = 1 then sequence_of_statements_1;
end if;

if x = 1 then sequence_of_statements_1 ;
else sequence_of_statements_N ;
end if;

if x = 1 then sequence_of_statements_1 ;
elsif x = 2 then sequence_of_statements_2 ;
else sequence_of_statements_N ;
end if;

If you are interested to learn more, you can search for the online SQL training or online PL/SQL training. You can find them for free. Or you can go to your local SQL training and local PL/SQL training. This knowledge will be useful for you.