{"id":3975,"date":"2025-06-07T08:38:22","date_gmt":"2025-06-07T08:38:22","guid":{"rendered":"https:\/\/w3buddy.com\/?post_type=cposts&#038;p=3975"},"modified":"2025-06-07T10:01:13","modified_gmt":"2025-06-07T10:01:13","slug":"sql-create-table","status":"publish","type":"cposts","link":"https:\/\/w3buddy.com\/blog\/notes\/sql\/sql-create-table\/","title":{"rendered":"SQL CREATE TABLE"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Creating tables is fundamental \u2014 tables store your data in rows and columns.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Basic Syntax<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><code>CREATE TABLE table_name (\n  column1 datatype &#91;constraints],\n  column2 datatype &#91;constraints],\n  ...\n);<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>table_name<\/code>: Name of your table.<\/li>\n\n\n\n<li><code>column1, column2<\/code>: Columns with their data types.<\/li>\n\n\n\n<li>Constraints like <code>PRIMARY KEY<\/code>, <code>NOT NULL<\/code> can be added.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Example<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><code>CREATE TABLE employees (\n  employee_id INT PRIMARY KEY,\n  first_name VARCHAR(50) NOT NULL,\n  last_name VARCHAR(50) NOT NULL,\n  hire_date DATE,\n  salary DECIMAL(10, 2)\n);<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Creates an <code>employees<\/code> table with 5 columns and constraints.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Notes by DBMS<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Data types and syntax can slightly vary across DBMS.<\/li>\n\n\n\n<li>In <strong>Oracle<\/strong>, use <code>NUMBER<\/code> instead of <code>INT<\/code>.<\/li>\n\n\n\n<li>Add <code>AUTO_INCREMENT<\/code> (MySQL) or <code>IDENTITY<\/code> (SQL Server) for auto-generated IDs.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\udde0 Quick Recap<\/h2>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th>Key Point<\/th><th>Explanation<\/th><\/tr><\/thead><tbody><tr><td>Command<\/td><td><code>CREATE TABLE<\/code> with columns<\/td><\/tr><tr><td>Columns &amp; Data Types<\/td><td>Define structure of data<\/td><\/tr><tr><td>Constraints<\/td><td>Control data integrity<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83d\udca1 Always plan table structure carefully before creating it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating tables is fundamental \u2014 tables store your data in rows and columns. \ud83d\udd39 Basic Syntax \ud83d\udd39 Example Creates an employees table with 5 columns and constraints. \ud83d\udd39 Notes by DBMS \ud83e\udde0 Quick Recap Key Point Explanation Command CREATE TABLE with columns Columns &amp; Data Types Define structure of data Constraints Control data integrity \ud83d\udca1 [&hellip;]<\/p>\n","protected":false},"template":"","meta":{"googlesitekit_rrm_CAowu461DA:productID":""},"categories":[952,979],"class_list":["post-3975","cposts","type-cposts","status-publish","hentry","category-notes","category-sql"],"_links":{"self":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts\/3975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts"}],"about":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/types\/cposts"}],"wp:attachment":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=3975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=3975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}