No products in the cart.

Write SQL Query to Create a …

CBSE, JEE, NEET, CUET

CBSE, JEE, NEET, CUET

Question Bank, Mock Tests, Exam Papers

NCERT Solutions, Sample Papers, Notes, Videos

Write SQL Query to Create a Database “Product”
  • 1 answers

Pranab Jyoti Roy 4 years, 3 months ago

search Sign InHomeCoursesAlgorithmskeyboard_arrow_downData Structureskeyboard_arrow_downLanguageskeyboard_arrow_downInterview Cornerkeyboard_arrow_downGATEkeyboard_arrow_downCS Subjectskeyboard_arrow_downStudentkeyboard_arrow_downGBlogPuzzlesWhat's New ? ▲ SQL | CREATE Last Updated: 21-03-2018 There are two CREATE statements available in SQL: CREATE DATABASECREATE TABLE CREATE DATABASE A Database is defined as a structured set of data. So, in SQL the very first step to store the data in a well structured manner is to create a database. The CREATE DATABASE statement is used to create a new database in SQL. Syntax: CREATE DATABASE database_name; database_name: name of the database. Example Query: This query will create a new database in SQL and name the database as my_database. search Sign InHomeCoursesAlgorithmskeyboard_arrow_downData Structureskeyboard_arrow_downLanguageskeyboard_arrow_downInterview Cornerkeyboard_arrow_downGATEkeyboard_arrow_downCS Subjectskeyboard_arrow_downStudentkeyboard_arrow_downGBlogPuzzlesWhat's New ? ▲ SQL | CREATE Last Updated: 21-03-2018 There are two CREATE statements available in SQL: CREATE DATABASECREATE TABLE CREATE DATABASE A Database is defined as a structured set of data. So, in SQL the very first step to store the data in a well structured manner is to create a database. The CREATE DATABASE statement is used to create a new database in SQL. Syntax: CREATE DATABASE database_name; database_name: name of the database. Example Query: This query will create a new database in SQL and name the database as my_database. CREATE DATABASE my_database; CREATE TABLE We have learned above about creating databases. Now to store the data we need a table to do that. The CREATE TABLE statement is used to create a table in SQL. We know that a table comprises of rows and columns. So while creating tables we have to provide all the information to SQL about the names of the columns, type of data to be stored in columns, size of the data etc. Let us now dive into details on how to use CREATE TABLE statement to create tables in SQL. Syntax: CREATE TABLE table_name ( column1 data_type(size), column2 data_type(size), column3 data_type(size), .... ); table_name: name of the table. column1 name of the first column. data_type: Type of data we want to store in the particular column. For example,int for integer data. size: Size of the data we can store in a particular column. For example if for a column we specify the data_type as int and size as 10 then this column can store an integer number of maximum 10 digits. Example Query: This query will create a table named Students with three columns, ROLL_NO, NAME and SUBJECT. CREATE TABLE Students ( ROLL_NO int(3), NAME varchar(20), SUBJECT varchar(20), ); This query will create a table named Students. The ROLL_NO field is of type int and can store an integer number of size 3. The next two columns NAME and SUBJECT are of type varchar and can store characters and the size 20 specifies that these two fields can hold maximum of 20 characters. This article is contributed by Harsh Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
http://mycbseguide.com/examin8/

Related Questions

myCBSEguide App

myCBSEguide

Trusted by 1 Crore+ Students

Test Generator

Test Generator

Create papers online. It's FREE.

CUET Mock Tests

CUET Mock Tests

75,000+ questions to practice only on myCBSEguide app

Download myCBSEguide App