Oracle Create Table หลังจากที่ทำการ Create User พร้อม Grant สิทธิ์ต่าง ๆ แล้ว เรามาลองทำการ สร้าง Table ไว้ใช้งานกันครับ
Oracle Create User & Grant
เปิดโปรแกรม PL/SQL
Login myuser/mypassword เลือก TNS Name ชื่อ TCDB ที่เราได้สร้างจาก Net Manager
เข้าสู่หน้าจอของโปรแกรม PL/SQL เมื่อเลือกมุมมองของ My Objects จะปรากฏว่าตอนนี้ยังไม่มี Table ย่อย
คลิกขวาที่ Table เลือก New เพื่อทำการสร้าง Table ขึ้นมาใหม่ ในบทเรียนนี้ผมจะใช้ Table 3 ตัว

1.ตาราง customer
Table customercreate table customer
(
CustomerID varchar2(4),
Name varchar2(50),
Email varchar2(50),
CountryCode varchar2(3),
Budget number,
Used number
);
tablespace SYSTEM
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table customer
add constraint PK_CustomerID primary key (CUSTOMERID);
ระบุ Table Name
ระบุ Field & Column
ระบุ Key และเลือก Apply เพื่อ Create Table
2.ตาราง country
Table countrycreate table country
(
CountryCode varchar2(2),
CountryName varchar2(50)
)
tablespace SYSTEM
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table country
add constraint PK_CountryCode primary key (COUNTRYCODE);
ระบุ Table Name
ระบุ Field & Column
ระบุ Key และเลือก Apply เพื่อ Create Table
3.ตาราง audit_log
Table audit_logcreate table audit_log
(
AuditID varchar2(4),
CustomerID varchar2(4),
Date_Log date,
Used number
)
tablespace SYSTEM
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table audit_log
add constraint PK_AuditID primary key (AUDITID);
ระบุ Table Name
ระบุ Field & Column
ระบุ Key และเลือก Apply เพื่อ Create Table
การเพิ่มข้อมูลลงใน Table สามารถเพิ่มโดยการคลิกขวาที่ Table และเลือก Edit

หากต้องการ Save ให้กด (F8) และ ยืนยัน Commit Transaction กด (F10)
ข้อมูลแต่ล่ะ Table ดังนี้
Table customer
Table country
Table audit
|