0% found this document useful (0 votes)
5 views2 pages

HIMANSHU - 22CS007-Database Management System - 3rdsem-2023 - DDL Command - CREATE TABLE

File for DBMS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

HIMANSHU - 22CS007-Database Management System - 3rdsem-2023 - DDL Command - CREATE TABLE

File for DBMS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Department of Computer Science & Engineering

LAB MANUAL

22CS007-Database Management System - 3rdSem-2023

Student Name HIMANSHU

Email [email protected]

Course Name 22CS007-Database Management


System - 3rdSem-2023

Faculty Incharge
______________
Department of CSE Lab Manual: 22CS007-Database Management System - 3rdSem-2023

Aim: DDL Command - CREATE TABLE


SQL, or Structured Query Language, is a language designed to allow both technical and non-
technical users query, manipulate, and transform data from a relational database. And due to
its simplicity, SQL databases provide safe and scalable storage for millions of websites and
mobile applications.
There are many popular SQL databases including SQLite, MySQL, Postgres, Oracle and
Microsoft SQL Server. All of them support the common SQL language standard, which is
what this site will be teaching, but each implementation can differ in the additional features
and storage types it supports.
SQL Table
SQL Table is a collection of data that is organized in terms of rows and columns. In DBMS,
the table is known as relation and row as a tuple. Table is a simple form of data storage. A
table is also considered as a convenient representation of relations.
Create Table
When you have new entities and relationships to store in your database, you can create a new
database table using the CREATE TABLE statement.
CREATE TABLE IF NOT EXISTS table_name(
column1 DataType TableConstraint DEFAULT default_value,
column2 DataType TableConstraint DEFAULT default_value,
column3 DataType TableConstraint DEFAULT default_value,
....
);
The structure of the new table is defined by its table schema, which defines a series of
columns. Each column has a name, the type of data allowed in that column, an optional table
constraint on values being inserted, and an optional default value.
If there already exists a table with the same name, the SQL implementation will usually
throw an error, so to suppress the error and skip creating a table if one exists, you can use the
IF NOT EXISTS clause.
Here's an example schema for the Employee table
CREATE TABLE employee (
empId INT ,
empName VARCHAR(50),
joining DATE,
salary INT);

Task : Create a student table with the following columns:


rollNo INT,
studentName VARCHAR(50),
branch VARCHAR(10),
semester INT

Solution:
CREATE TABLE student (
rollNo INT,
studentName VARCHAR(50),
branch VARCHAR(10),
semester INT
);

HIMANSHU
2 [email protected]

You might also like