Contoh Perintah DDL (Data Definition Language) pada Oracle

Data Definition Language (DDL)

Statement Data Definition Language (DDL) merupakan bagian dari statement SQL yang digunakan untuk menciptakan, memodifikasi, atau menghapus struktur tabel database.
Pernyataan DDL terdiri atas :
PERINTAH DDL
KETERANGAN
CREATE TABLE
Perintah untuk menciptakan tabel
DROP TABLE
Perintah untuk menghapus tabel
ALTER TABLE
Perintah untuk mengubah struktur tabel
RENAME
Perintah untuk mengubah nama tabel
TRUNCATE
Perintah untuk mengosongkan tabel
Aturan nama tabel dan nama kolom dalam Oracle :
  • Harus dimulai dengan huruf
  • Memiliki panjang 1 – 30 karakter 
  • Dapat berupa gabungan dari huruf , angka dan karakter spesial: A – Z, a – z, 0 – 9, …., $ dan # 
  • Tidak boleh ada nama tabel dan kolom yang sama dengan obyek database lainnya yang ada dalam database yang dimiliki oleh user yang sama 
  • Tidak boleh merupakan statement Oracle. 

A. DDL : Perintah Create Table

Untuk dapat menciptakan tabel dalam database Oracle, seorang user harus memiliki hak akses untuk menciptakan tabel, yaitu hak akses CREATE TABLE (CREATE TABLE privilege).
Bentuk umum perintah CREATE TABLE adalah:
CREATE TABLE [schema.] table
(column datatype [DEFAULT expr] [, …..]); 
Dimana :
  • schema adalah nama user schema 
  • table adalah nama tabel 
  • DEFAULT expr mendefinisikan nilai default apabila nilai tidak didefinisikan saat menggunakan statement INSERT saat meng-inputkan data pada tabel 
  • column adalah nama kolom 
  • datatype adalah tipe data dan panjang kolom
 contoh perintah create table :
create table
  • Untuk melihat struktur tabel yang telah dibuat dalam Oracle, dapat digunakan perintah DESCRIBE (dapat disingkat dengan DESC)
Contoh: DESC petugas;  

B. DDL : Perintah ALTER TABLE 

Untuk Menambahkan tabel, berikut ini sintaksnya :
ALTER TABLE table
ADD (column datatype [DEFAULT expr]
[, column datatype] …); 
  • Untuk Memodifikasi Tabel
ALTER TABLE table MODIFY (column datatype [DEFAULT expr] [, column datatype] …);
  •  Untuk Menghapus Tabel
ALTER TABLE table DROP (column);
dimana: 
  • ADD|MODIFY|DROP adalah jenis modifikasi yang akan dilakukan
  • table adalah nama tabel
  • column adalah nama kolom
  • datatype adalah tipe data dan panjang dari kolom 
Contoh Penerapan Perintah Alter Table : 
1. Perintah Alter Table untuk Menambah Kolom atau Field
alter table tambah column

2. Perintah Alter Table untuk Memodifikasi Tipe Data Kolom yang Sudah Dibuat
alter table modify

CATATAN:
  • Pengubahan dimana ukuran kolom akan dikecilkan hanya dapat dilakukan apabila kolom hanya berisi nilai NULL atau apabila tabel belum memiliki record/baris data sama sekali. 
  • Pengubahan tipe data hanya dapat dilakukan apabila kolom berisi nilai NULL. 
  • Pengubahan terhadap nilai DEFAULT hanya akan berdampak pada peng-inputan data berikutnya dalam tabe.
3.  Perintah Alter Table untuk Menghapus Kolom.
Bisa dengan mengetikan sintaks berikut ini : ALTER TABLE petugas DROP COLUMN email; dimana :
petugas = nama tabel
email = nama kolom pada tabel petugas.

C. DDL : Perintah Drop Table 

sintaks : 
DROP TABLE table; 
dimana :
table = nama tabel.

D. DDL : Perintah Rename

Perintah RENAME digunakan untuk mengubah nama tabel.
Bentuk umum dari perintah RENAME : 
RENAME old_name TO new_name
dimana:
old_name merupakan nama tabel yang akan diubah namanya 
new_name merupakan nama tabel yang baru 
Contoh mengubah nama tabel PETUGAS menjadi PEGAWAI dan sebaliknya
  • RENAME petugas TO pegawai
  • RENAME pegawai TO petugas;

E. DDL : Perintah Truncate

Perintah TRUNCATE digunakan untuk menghapus semua baris/record dalam tabel dan melepaskan memori yang digunakan oleh tabel.
Bentuk umum perintah TRUNCATE:
TRUNCATE TABLE table
dimana:
table adalah nama tabel yang akan dihapus seluruh datanya.
Catatan :
Perintah TRUNCATE TABLE tidak dapat di- roll back.

Postingan terkait:

30 Tanggapan untuk "Contoh Perintah DDL (Data Definition Language) pada Oracle"

  1. makasih banyak sudah share
    siap min, makasih banyak sudah share
    solder uap

    BalasHapus
  2. Sometimes errors may possibly also happen as a consequence of some small mistakes. Those are decimals, comma, backspace, etc. Are you go through to QuickBooks Tech Support If you do not, we have been here that will help.

    BalasHapus
  3. QuickBooks Enterprise Tech Support Number has a team from it experts which can help you for several quickbooks technical issue releted to these :- QuickBooks Enterprise users usually are professionals or employees performing specific task defined inside their mind like purchase personal will create Purchase.

    BalasHapus
  4. Hope, you liked your site. If any method or technology you can not understand, if so your better choice is which will make call us at our Quickbooks Enhanced Payroll Customer Support.

    BalasHapus
  5. QuickBooks Customer Service Phone Number get you one-demand technical help for QuickBooks. QuickBooks allows a number of third-party software integration. QuickBooks software integration is one of the most useful solution provided by the application to control the accounting tasks in a less complicated and precise way. Need not bother about the costing of the software integration because it offers an array of pocket-friendly plans that can be used to control payroll with ease.

    BalasHapus
  6. If you'd like any help for QuickBooks errors from customer care to get the treatment for these errors and problems, it is simple to contact with QuickBooks Support Phone Number and obtain instant assistance with the guidance of our technical experts.

    BalasHapus
  7. QuickBooks Enterprise Technical Support Number offers you proper assistance if you require it. You can avail Enterprise Support using E-mail yet QuickBooks Enterprise support number serves to be the best type of assistance. Here our experts will answer your call and offer you perfect solutions on QuickBooks Enterprise resolving all of the issues faced by you.

    BalasHapus
  8. You named an error therefore we have the solution, this is the most luring top features of QuickBooks Enterprise Support Number channel available on a call at .You can quickly avail our other beneficial tech support team services easily once we are merely just one call definately not you.

    BalasHapus
  9. The best solutions are imperative when it comes to growth of the business enterprise enterprise. Therefore, QuickBooks is present for users around the globe even though the best tool to provide creative and innovative features for business account management to small and medium-sized business organizations. If you’re encountering any type of QuickBooks’ related problem, you will definately get all of that problems solved simply by using the QuickBooks Tech Support Number.

    BalasHapus
  10. QuickBooks Technical Support Number advisors are certified Pro-advisors’ and has forte in furnishing any kind of technical issues for QuickBooks. They've been expert and certified technicians of these domains like QuickBooks accounting,QuickBooks Payroll, Point of Sales, QuickBooks Merchant Services and Inventory issues to provide 24/7 service to your esteemed customers. QuickBooks Payroll Services provide solutions to your entire QuickBooks problem as well as assists in identifying the errors with QuickBooks data files and diagnose them thoroughly before resolving these issues.

    BalasHapus
  11. Have you been scratching the top and stuck together with your QuickBooks related issues, you'll be just one single click definately not our expert tech support team for your QuickBooks Tech Support Number related issues.

    BalasHapus
  12. The Intuit QuickBooks Support usually takes in any types of queries associated with installing a particular form of QuickBooks software, to know about the newly available subscription plans, backing up data, fixing errors with a saved QOB file and a lot more.

    BalasHapus
  13. Getting instant and effective help for almost any case of concern is really what the user’s desire for. With QuickBooks, it is possible to relax knowing about having the most desirable and efficacious help on every issue that you could encounter yourself with. You just need to avail the help through the technical experts by dialing the Support For QuickBooks.

    BalasHapus
  14. At QuickBooks Support Number, you will find solution each and every issue that bothers your projects and creates hindrance in running your business smoothly.

    BalasHapus
  15. QuickBooks is present for users around the globe even though the best tool to provide creative and innovative features for business account management to small and medium-sized business organizations. If you’re encountering any type of QuickBooks’ related problem, you will definately get all of that problems solved simply by using the QuickBooks Support Phone Number.

    BalasHapus
  16. These are typically prompt and responsive in resolving the matter. Resolve any QuicKbooks Customer Tech Support Phone Number issue because of the QB technicians instantly . Business proprietor these days completely rely on QuickBooks in order to avoid the effort for the types of work. The popular QB versions: Pro Advisor, Payroll and Enterprise have brought a revolution in the current business competition .

    BalasHapus
  17. QuickBooks Enterprise has its own awesome features which can make it more reliable and efficient. Let’s see some awesome features that could have caused it really is so popular. If you should be also a QuickBooks user and would like to find out more concerning this software you might check out the QuickBooks Enterprise Support USA.

    BalasHapus
  18. QuickBooks related issues. Either it is day or night, we offer hassle-free tech support team for QuickBooks Support. and its own associated software in minimum possible time. Our dedicated technical team can be acquired to be able to 24X7, 365 days a year to make sure comprehensive support and services at any hour. We assure you the quickest solution on most your QuickBooks software related issues.

    BalasHapus
  19. QuickBooks Payroll Tech Support Number software helps you to prepare your invoices, manage your online business payrolls, track your online business inventory, control cash flow, and get tax-ready.

    BalasHapus
  20. Every user are certain to get 24/7 support services with this online technical experts using QuickBooks Support Phone Number. When you’re stuck in times which you can’t discover ways to eradicate a concern, all that is necessary would be to dial QuickBooks support telephone number. Remain calm; they will inevitably and instantly solve your queries. Consist of a beautiful bunch of accounting versions, viz., QuickBooks Pro, QuickBooks Premier, QuickBooks Enterprise, QuickBooks POS, QuickBooks Mac, QuickBooks Windows, and QuickBooks Payroll, QuickBooks has grown to become a dependable accounting software that one may tailor depending on your industry prerequisite. As well as it, our QuickBooks Payroll Support Number will bring in dedicated and diligent back-end helps for you for in case you find any inconveniences in operating any of these versions.

    BalasHapus
  21. Earnings: to begin with, a business can only survive if it is making adequate profits to smoothly run the operations associated with the work. Our QuickBooks Support team will surely show you in letting you know about the profit projections in QuickBooks.

    BalasHapus
  22. Since volume of issues are enormous on occasion, QuickBooks Tech Support could seem very basic to you personally so when an effect could make you're taking backseat and you'll not ask for every help. Let’s update you because of the proven fact that this matter is immensely faced by our customers.

    BalasHapus
  23. Infycle Technologies, the best software training institute in Chennai offers the leading Data Science course in Chennai for tech professionals, freshers, and students at the best offers. In addition to the Data Science course, other in-demand courses such as Python, Cyber Security, Selenium, Oracle, Java, Power BI, Digital Marketing also will be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7504633633 to get more info and a free demo.

    BalasHapus