{"id":14770,"date":"2023-02-03T10:48:12","date_gmt":"2023-02-03T10:48:12","guid":{"rendered":"http:\/\/new.cloudpap.com\/?post_type=docs&#038;p=14770"},"modified":"2023-02-03T10:50:44","modified_gmt":"2023-02-03T10:50:44","password":"","slug":"how-to-create-a-table-in-sql","status":"publish","type":"docs","link":"https:\/\/cloudpap.com\/blog\/docs\/how-to-create-a-table-in-sql\/","title":{"rendered":"How to Create a Table in SQL"},"content":{"rendered":"\n<p>To create a table in SQL, you use the CREATE TABLE statement followed by the table name and the list of columns and their data types. <\/p>\n\n\n\n<p>Here is the syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scss\n<code><strong><em>CREATE TABLE table_name (\n   column1 datatype(size),\n   column2 datatype(size),\n   column3 datatype(size),\n   ...\n);\n<\/em><\/strong><\/code><\/code><\/pre>\n\n\n\n<p>For example, if you want to create a table named <code>students<\/code> with columns <code>id<\/code>, <code>name<\/code>, <code>age<\/code>, and <code>gender<\/code>, you can use the following SQL statement:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sql\n<code><strong><em>CREATE TABLE students (\n   id INT PRIMARY KEY,\n   name VARCHAR(50),\n   age INT,\n   gender CHAR(1)\n);<\/em><\/strong>\n<\/code><\/code><\/pre>\n\n\n\n<p>Here, the <code>id<\/code> column is defined as an <code>INT<\/code> data type with a <code>PRIMARY KEY<\/code> constraint, which means it will be the unique identifier for each record in the table. <\/p>\n\n\n\n<p>The <code>name<\/code> column is defined as a <code>VARCHAR<\/code> with a size of 50 characters, <code>age<\/code> as <code>INT<\/code>, and <code>gender<\/code> as <code>CHAR<\/code> with a size of 1 character.<\/p>\n\n\n\n<p>It&#8217;s important to carefully choose the data types for each column, as this will affect how data is stored and retrieved in the table. You can use different data types such as <code>INT<\/code>, <code>VARCHAR<\/code>, <code>CHAR<\/code>, <code>DATE<\/code>, <code>DECIMAL<\/code>, etc. based on the type of data you need to store.<\/p>\n\n\n\n<p>Once you have executed the CREATE TABLE statement, a new table with the specified columns and data types will be created in the database. You can then use INSERT statements to add data to the table.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To create a table in SQL, you use the CREATE TABLE statement followed by the table name and the list of columns and their data types. Here is the syntax: For example, if you want to create a table named students with columns id, name, age, and gender, you can use the following SQL statement:&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"doc_category":[244],"doc_tag":[],"class_list":["post-14770","docs","type-docs","status-publish","hentry","doc_category-database"],"year_month":"2026-04","word_count":222,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Cloud Pap","author_nicename":"cloudpapadmin2023","author_url":"https:\/\/cloudpap.com\/blog\/author\/cloudpapadmin2023\/"},"doc_category_info":[{"term_name":"Database","term_url":"https:\/\/cloudpap.com\/blog\/docs-category\/database\/"}],"doc_tag_info":[],"_links":{"self":[{"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/docs\/14770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/comments?post=14770"}],"version-history":[{"count":0,"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/docs\/14770\/revisions"}],"wp:attachment":[{"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/media?parent=14770"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/doc_category?post=14770"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/doc_tag?post=14770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}