Sunday, June 14, 2020

Create - syntax with examples

create ddl in dbms

Create is a powerful DDL command, used for creating database structure.

Create database

The first step in getting started with SQL, is to create a database and then add your tables into it.

Syntax :  create database database_name

Example: create database BloggingDb

Congratulations on creating your first database! 👏🏼

You can find it under ‘Databases’ in left panel in SSMS. Ensure you are in this database, before creating your tables here.

Create tables

To your database, you may start adding your tables.

Syntax: create table table_name

(col_name1 datatype(size if reqd),

col_name2 datatype(size if reqd)

.

)

Example:

create table table1

(

Id int not null,

FirstName varchar(50) not null,

LastName varchar(50) null,

Height float,

Weight float

)

When you do not specify whether the column can  accept null or not, by default SQL Server allows null values.

Happy SQLing!

Please post your comments  (+ve or -ve, even neutral 😅 ) and questions and feel free share it to with your friends .

Cos sharing is caring..! 😎

Until next blog,

Vino BI Dev

No comments:

Post a Comment

Schema in DBMS

A schema is a collection of objects (tables, stored procedures, functions, etc) in a database, that are associated to one another. A schema ...