{"id":313,"date":"2025-03-25T13:19:16","date_gmt":"2025-03-25T06:19:16","guid":{"rendered":"https:\/\/binus.ac.id\/semarang\/information-systems\/?p=313"},"modified":"2025-03-25T14:05:27","modified_gmt":"2025-03-25T07:05:27","slug":"313","status":"publish","type":"post","link":"https:\/\/binus.ac.id\/semarang\/information-systems\/2025\/03\/25\/313\/","title":{"rendered":"Modifying Table using SQL(Oralce APEX)"},"content":{"rendered":"<p style=\"text-align: center\"><strong>Modifying Table using SQL<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">SQL databases organize data and relationships within tables. Sometimes, these tables also need modifications to meet new requirements. While all SQL table structures can be altered, some changes are simpler to implement than others.<br \/>\nThere are multiple way to modify a table :<\/p>\n<p style=\"text-align: justify\">1. Adding a Column The most easiest one can alter from a table is to add a new field to the table. This is generally a very simple and risk operation as it doesn&#8217;t have any dependency on the other components within the database.<\/p>\n<p style=\"text-align: justify\">Syntax: <strong>ALTER<\/strong> <strong>TABLE<\/strong> NamaTabel <strong>ADD<\/strong> NamaKolom TipeData;<\/p>\n<p style=\"text-align: justify\">2. Modifying a Column To change the data type, size, or constraints of an existing column, the MODIFY or ALTER COLUMN clause is employed, depending on the SQL dialect. It&#8217;s important to note that some modifications may be restricted based on the existing data within the column.<\/p>\n<p style=\"text-align: justify\">Syntax: <strong>ALTER<\/strong> <strong>TABLE<\/strong> NamaTabel <strong>ALTER<\/strong> <strong>COLUMN<\/strong> NamaKolom TipeDataBaru;<\/p>\n<p style=\"text-align: justify\"><strong>Example<\/strong>: <strong>ALTER<\/strong> <strong>TABLE<\/strong> Kelas <strong>ALTER<\/strong> <strong>COLUMN<\/strong> umur VARCHAR(2);<\/p>\n<p style=\"text-align: justify\">3. Deleting a Column To remove an unnecessary column from a table, the DROP COLUMN clause is used. This action is irreversible; once a column is dropped, all data contained within it is permanently deleted.<\/p>\n<p style=\"text-align: justify\">Syntax: <strong>ALTER<\/strong> <strong>TABLE<\/strong> NamaTabel <strong>DROP<\/strong> <strong>COLUMN<\/strong> NamaKolom;<\/p>\n<p style=\"text-align: justify\"><strong>Example<\/strong>: Removing the Email column from the Customers table: ALTER TABLE Mobil DROP COLUMN Banyak_Ban;<\/p>\n<p style=\"text-align: justify\">4. Renaming a Column To change the name of an existing column, the RENAME COLUMN clause is utilized. The exact syntax can vary between different SQL databases.<\/p>\n<p style=\"text-align: justify\">Syntax: ALTER TABLE NamaTabel RENAME COLUMN NamaLama TO NamaBaru;<\/p>\n<p style=\"text-align: justify\">Example: <strong>ALTER<\/strong> <strong>TABLE<\/strong> Rumah <strong>RENAME<\/strong> <strong>COLUMN<\/strong> Luas <strong>TO<\/strong> Besar;<\/p>\n<p style=\"text-align: justify\">5. Adding Constraints Constraints are the rules at the table level, ensuring the accuracy and reliability of the data. Common constraints include that are being used to make one unique or become the main way to distinct one table from another.<\/p>\n<p style=\"text-align: justify\">Syntax: <strong>ALTER<\/strong> <strong>TABLE<\/strong> NamaTabel <strong>ADD<\/strong> <strong>CONSTRAINT<\/strong> NamaCostraint TipeCosntraint (NamaKolom);<\/p>\n<p style=\"text-align: justify\"><strong>Example<\/strong>: <strong>ALTER<\/strong> <strong>TABLE<\/strong> Pekerja <strong>ADD<\/strong> <strong>CONSTRAINT<\/strong> <strong>UNIQUE_EMAIL<\/strong> <strong>UNIQUE<\/strong> (Email); This make all values in the Email column unique across the Employees table.<\/p>\n<p style=\"text-align: justify\">6. Dropping Constraints To remove an existing constraint from a table, the DROP CONSTRAINT clause is used. The specific syntax may vary depending on the database system.<\/p>\n<p style=\"text-align: justify\">Syntax:<br \/>\nALTER TABLE NamaTabel DROP CONSTRAINT NamaConstraint;<\/p>\n<p style=\"text-align: justify\"><strong>Example<\/strong>: <strong>Dropping<\/strong> the UNIQUE_EMAIL constraint from the Mobil table: <strong>ALTER TABLE<\/strong> <strong>Mobil<\/strong> DROP <strong>CONSTRAINT<\/strong> <strong>UNIQUE_EMAIL<\/strong>;<br \/>\nThis removes the uniqueness requirement from the Email column, allowing duplicate entries.<\/p>\n<p style=\"text-align: justify\">7. Renaming a Table If you are unhappy with the name and want to change the already created table name. To change the name of a table, use RENAME TO.<\/p>\n<p style=\"text-align: justify\">Syntax: <strong>ALTER<\/strong> <strong>TABLE<\/strong> NamaTabelLama <strong>RENAME<\/strong> <strong>TO<\/strong> NamaTabelBaru;<\/p>\n<p style=\"text-align: justify\">Example: Renaming the Customers table to Clients: <strong>ALTER<\/strong> <strong>TABLE<\/strong> Mobil <strong>RENAME<\/strong> <strong>TO<\/strong> Mobilku;<\/p>\n<p style=\"text-align: justify\">8. Truncating a Table To remove all data from a table without deleting the table itself, the TRUNCATE TABLE statement is used. This operation is faster than deleting all rows individually and resets any auto-increment counters.<\/p>\n<p style=\"text-align: justify\">Syntax: TRUNCATE TABLE NamaTabel;<br \/>\n<strong>Example<\/strong>: <strong>TRUNCATE<\/strong> <strong>TABLE<\/strong> Sales;<br \/>\nThis command deletes all rows in the Sales table, effectively resetting it while preserving its structure for future data.<\/p>\n<p style=\"text-align: justify\">9. Setting Unused Columns If you don&#8217;t want to delete you can instead of deleting a column, you can hide it, which is faster for big tables.<\/p>\n<p style=\"text-align: justify\">Syntax : <strong>ALTER<\/strong> <strong>TABLE<\/strong> NamaTable <strong>SET<\/strong> <strong>UNUSED<\/strong> (NamaKolom);<\/p>\n<p style=\"text-align: justify\"><strong> Example<\/strong> : <strong>ALTER<\/strong> <strong>TABLE<\/strong> Kelas <strong>SET UNUSED<\/strong> (TanggalKelas);<\/p>\n<p>DBMS : <strong>Oralce APEX<\/strong><\/p>\n<p style=\"text-align: left\">Link Infographic: https:\/\/www.canva.com\/design\/DAGgqwYZYOI\/80A8ctG0mzjrK4b1bkijqg\/edit?utm_content=DAGgqwYZYOI&amp;utm_campaign=designshare&amp;utm_medium=link2&amp;utm_source=sharebutton<\/p>\n<p style=\"text-align: justify\">References :<\/p>\n<p style=\"text-align: justify\">https:\/\/support.microsoft.com\/en-us\/office\/create-or-modify-tables-or-indexes-by-using-a-data-definition-query-d935e129-229b-48d8-9f2d-1d4ee87f418e<br \/>\nhttps:\/\/study.com\/academy\/lesson\/modifying-tables-using-sql.html<br \/>\nhttps:\/\/yasirutomo.com\/sql-tutorial-ddl-create-alter-dan-drop-database-table\/<\/p>\n<p>Editor : Edi Purnomo Putra<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-316\" src=\"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-content\/uploads\/sites\/6\/2025\/03\/White-Simple-Travel-Instagram-Post.png\" alt=\"\" width=\"1080\" height=\"1080\" srcset=\"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-content\/uploads\/sites\/6\/2025\/03\/White-Simple-Travel-Instagram-Post.png 1080w, https:\/\/binus.ac.id\/semarang\/information-systems\/wp-content\/uploads\/sites\/6\/2025\/03\/White-Simple-Travel-Instagram-Post-300x300.png 300w, https:\/\/binus.ac.id\/semarang\/information-systems\/wp-content\/uploads\/sites\/6\/2025\/03\/White-Simple-Travel-Instagram-Post-1024x1024.png 1024w, https:\/\/binus.ac.id\/semarang\/information-systems\/wp-content\/uploads\/sites\/6\/2025\/03\/White-Simple-Travel-Instagram-Post-150x150.png 150w, https:\/\/binus.ac.id\/semarang\/information-systems\/wp-content\/uploads\/sites\/6\/2025\/03\/White-Simple-Travel-Instagram-Post-768x768.png 768w, https:\/\/binus.ac.id\/semarang\/information-systems\/wp-content\/uploads\/sites\/6\/2025\/03\/White-Simple-Travel-Instagram-Post-480x480.png 480w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Modifying Table using SQL &nbsp; SQL databases organize data and relationships within tables. Sometimes, these tables also need modifications to meet new requirements. While all SQL table structures can be altered, some changes are simpler to implement than others. There are multiple way to modify a table : 1. Adding a Column The most easiest [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":342,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-313","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles"],"_links":{"self":[{"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/posts\/313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/comments?post=313"}],"version-history":[{"count":6,"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/posts\/313\/revisions"}],"predecessor-version":[{"id":338,"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/posts\/313\/revisions\/338"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/media\/342"}],"wp:attachment":[{"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/media?parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/categories?post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/binus.ac.id\/semarang\/information-systems\/wp-json\/wp\/v2\/tags?post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}