SQL Create Command: Syntax and Examples for Creating Databases and Tables, Assignments of Computer Science

Learn about the sql create command, which is used to create databases and tables in relational database management systems. Discover the syntax and examples for creating databases and tables, as well as the most commonly used datatypes for table columns.

Typology: Assignments

2021/2022

Uploaded on 03/30/2022

asimahsan45
asimahsan45 🇵🇰

5

(1)

40 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
SQL:createcommand
createis a DDL SQL command used to create a table or a
database in relational database management system.
Creating a Database
To create a database in RDBMS,createcommand is used.
Following is the syntax,
CREATE DATABASE <DB_NAME>;
Example for creating Database
CREATE DATABASE Test;
The above command will create a database namedTest,
which will be an empty schema without any table.
To create tables in this newly created database, we can again
use thecreatecommand.
Creating a Table
createcommand can also be used to create tables. Now when
we create a table, we have to specify the details of the
pf3
pf4

Partial preview of the text

Download SQL Create Command: Syntax and Examples for Creating Databases and Tables and more Assignments Computer Science in PDF only on Docsity!

SQL: create command

create is a DDL SQL command used to create a table or a database in relational database management system.

Creating a Database

To create a database in RDBMS, create command is used. Following is the syntax, CREATE DATABASE <DB_NAME>; Example for creating Database CREATE DATABASE Test; The above command will create a database named Test , which will be an empty schema without any table. To create tables in this newly created database, we can again use the create command.

Creating a Table

create command can also be used to create tables. Now when we create a table, we have to specify the details of the

columns of the tables too. We can specify the names and datatypes of various columns in the create command itself. Following is the syntax, CREATE TABLE <TABLE_NAME> ( column_name1 datatype1, column_name2 datatype2, column_name3 datatype3, column_name4 datatype ); create table command will tell the database system to create a new table with the given table name and column information. Example for creating Table CREATE TABLE Student( student_id INT, name VARCHAR( 100 ), age INT);

INT used for columns which will store integer values. FLOAT used for columns which will store float values. DOUBLE used for columns which will store float values. VARCHA R used for columns which will be used to store characters and integers, basically a string. CHAR used for columns which will store char values(single character). DATE used for columns which will store date values. TEXT used for columns which will store text which is generally long in length. For example, if you create a table for storing profile information of a social networking website, then for about me section you can have a column of type TEXT.