{"id":91,"date":"2026-03-06T07:10:28","date_gmt":"2026-03-06T07:10:28","guid":{"rendered":"https:\/\/gigz.pk\/sql\/?post_type=lesson&#038;p=91"},"modified":"2026-03-16T18:52:10","modified_gmt":"2026-03-16T18:52:10","slug":"create-table","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/sql\/lesson\/create-table\/","title":{"rendered":"CREATE TABLE"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>CREATE TABLE<\/code> statement is used to create a new table in a database. A table is a collection of related data organized in rows and columns.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE TABLE table_name (<br>    column1 datatype [constraint],<br>    column2 datatype [constraint],<br>    ...<br>);<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Explanation<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>table_name<\/strong> \u2013 The name of the table you want to create.<\/li>\n\n\n\n<li><strong>column1, column2, \u2026<\/strong> \u2013 Names of the columns in the table.<\/li>\n\n\n\n<li><strong>datatype<\/strong> \u2013 Type of data the column can hold (e.g., INT, VARCHAR, DATE).<\/li>\n\n\n\n<li><strong>constraint<\/strong> \u2013 Optional rules for the column, such as PRIMARY KEY, NOT NULL, UNIQUE.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Common Data Types<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>INT<\/strong> \u2013 Whole numbers<\/li>\n\n\n\n<li><strong>VARCHAR(size)<\/strong> \u2013 Text with a maximum length<\/li>\n\n\n\n<li><strong>DATE<\/strong> \u2013 Date values<\/li>\n\n\n\n<li><strong>FLOAT<\/strong> \u2013 Decimal numbers<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Common Constraints<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PRIMARY KEY<\/strong> \u2013 Uniquely identifies each row<\/li>\n\n\n\n<li><strong>NOT NULL<\/strong> \u2013 Ensures the column cannot have empty values<\/li>\n\n\n\n<li><strong>UNIQUE<\/strong> \u2013 Ensures all values in the column are unique<\/li>\n\n\n\n<li><strong>FOREIGN KEY<\/strong> \u2013 Links a column to a column in another table<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE TABLE Students (<br>    StudentID INT PRIMARY KEY,<br>    FirstName VARCHAR(50) NOT NULL,<br>    LastName VARCHAR(50) NOT NULL,<br>    BirthDate DATE,<br>    Email VARCHAR(100) UNIQUE<br>);<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Explanation of Example<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>StudentID<\/strong> \u2013 Integer column and primary key<\/li>\n\n\n\n<li><strong>FirstName<\/strong> and <strong>LastName<\/strong> \u2013 Text columns that cannot be empty<\/li>\n\n\n\n<li><strong>BirthDate<\/strong> \u2013 Stores the student\u2019s date of birth<\/li>\n\n\n\n<li><strong>Email<\/strong> \u2013 Stores student email and must be unique<\/li>\n<\/ul>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/sql\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">Intermediate SQL for Data Professionals (SQL-201) >Table Management > CREATE TABLE<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773574529626\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n","protected":false},"menu_order":38,"template":"","class_list":["post-91","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CREATE TABLE - SQL Learning Hub<\/title>\n<meta name=\"description\" content=\"&quot;Learn SQL CREATE TABLE syntax, data types, and constraints with examples. Step-by-step guide for beginners and database designers.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/sql\/lesson\/create-table\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CREATE TABLE - SQL Learning Hub\" \/>\n<meta property=\"og:description\" content=\"&quot;Learn SQL CREATE TABLE syntax, data types, and constraints with examples. Step-by-step guide for beginners and database designers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/sql\/lesson\/create-table\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Learning Hub\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-16T18:52:10+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/create-table\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/create-table\\\/\",\"name\":\"CREATE TABLE - SQL Learning Hub\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/#website\"},\"datePublished\":\"2026-03-06T07:10:28+00:00\",\"dateModified\":\"2026-03-16T18:52:10+00:00\",\"description\":\"\\\"Learn SQL CREATE TABLE syntax, data types, and constraints with examples. Step-by-step guide for beginners and database designers.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/create-table\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/create-table\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/create-table\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Intermediate SQL for Data Professionals (SQL-201) >Table Management > CREATE TABLE\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/\",\"name\":\"SQL Learning Hub\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CREATE TABLE - SQL Learning Hub","description":"\"Learn SQL CREATE TABLE syntax, data types, and constraints with examples. Step-by-step guide for beginners and database designers.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/sql\/lesson\/create-table\/","og_locale":"en_US","og_type":"article","og_title":"CREATE TABLE - SQL Learning Hub","og_description":"\"Learn SQL CREATE TABLE syntax, data types, and constraints with examples. Step-by-step guide for beginners and database designers.","og_url":"https:\/\/gigz.pk\/sql\/lesson\/create-table\/","og_site_name":"SQL Learning Hub","article_modified_time":"2026-03-16T18:52:10+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/sql\/lesson\/create-table\/","url":"https:\/\/gigz.pk\/sql\/lesson\/create-table\/","name":"CREATE TABLE - SQL Learning Hub","isPartOf":{"@id":"https:\/\/gigz.pk\/sql\/#website"},"datePublished":"2026-03-06T07:10:28+00:00","dateModified":"2026-03-16T18:52:10+00:00","description":"\"Learn SQL CREATE TABLE syntax, data types, and constraints with examples. Step-by-step guide for beginners and database designers.","breadcrumb":{"@id":"https:\/\/gigz.pk\/sql\/lesson\/create-table\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/sql\/lesson\/create-table\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/sql\/lesson\/create-table\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/sql\/"},{"@type":"ListItem","position":2,"name":"Intermediate SQL for Data Professionals (SQL-201) >Table Management > CREATE TABLE"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/sql\/#website","url":"https:\/\/gigz.pk\/sql\/","name":"SQL Learning Hub","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/sql\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/lesson\/91","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/media?parent=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}