The CREATE command in SQL

SQL stands for Structured Query Language, a programming language used to communicate with and manipulate databases. In this article, TipsMake will introduce the CREATE command in SQL to help you understand its syntax and usage.

To learn more about what SQL is, you can refer to TipsMake's article "What is SQL ?". This article will focus solely on the CREATE command in SQL.

The CREATE command in SQL

SQL has two built-in CREATE commands , including:

- Create Database

- CREATE TABLE

CREATE DATABASE command in SQL

In SQL, a database is defined as a sorted collection of data. Therefore, the first step in SQL to store sorted data is to create a database. The CREATE DATABASE command is used to create a new database in SQL.

Syntax:

CREATE DATABASE database_name;

In there:

database_name : the name of the database.

Example query:

This query will create a new database in SQL and name the database my_database:

CREATE DATABASE my_database;

The CREATE TABLE command in SQL

As TipsMake mentioned above, the CREATE DATABASE command is used to create a new database in SQL. To store data in SQL, you need a data table. The CREATE TABLE command is used to create a table in SQL.

A table consists of rows and columns. Therefore, when creating a table, you must provide information to SQL including column names, the type of data to be stored in the columns, and the size of the data.

Below is the syntax for the CREATE TABLE command to create a table in SQL.

Syntax:

CREATE TABLE table_name

(

column1 data_type(size),

column2 data_type(size),

column3 data_type(size),

.

);

In there:

table_name : the name of the table.

column1: the name of the first column.

data_type : The type of data you want to store in that specific column. For example, int for integer data.

- Size: The size of data we can store in a specific column. For example, if the data_type column is defined as int and the size is 10, then this column can store an integer, up to 10 digits.

Example query:

The query below creates a table named Students, which includes three columns: ROLL_NO, NAME, and SUBJECT:

CREATE TABLE Students

(

ROLL_NO int(3),

NAME varchar(20),

SUBJECT varchar(20),

);

The above query will create the Students table. The ROLL_NO field is of type int and can store integers with a size of 3. The next two columns, NAME and SUBJECT, are of type varchar, can store characters, and have a size of 20, meaning these fields can contain a maximum of 20 characters.

The article above, TipsMake has just introduced you to the CREATE command in SQL. Basically, there are two CREATE commands in SQL: CREATE DATABASE and CREATE TABLE. The next article, TipsMake will introduce you to the DELETE command in SQL .


If you have any questions or need clarification, please leave your comments below the article, and TipsMake will answer your questions as soon as possible.

Other SQL articles
  • GRANT, REVOKE in SQL

    các lệnh dcl trong sql được sử dụng để thực thi bảo mật cơ sở dữ liệu trong môi trường cơ sở dữ liệu người dùng. lệnh grant, revoke trong sql là 2 kiểu lệnh dcl. Để tìm hiểu rõ hơn về lệnh dcl cũng như lệnh grant, revoke trong sql, bạn đọc cùng tham khảo bài viết dưới đây của tipsmake.
  • The JOINS command in SQL

    thông thường, lệnh joins trong sql được sử dụng để kết nối các thông tin trong các bảng khác nhau, điều kiện joins là một phần trong truy vấn sql để truy xuất các hàng từ 2 bảng trở lên.
  • How to deploy SQL Server via PowerShell DSC

    hôm nay, tipsmake sẽ hướng dẫn các bạn cách triển khai sql server thông qua powershell dsc giúp bạn có thể sử dụng tính năng powershell mới quan lý cơ sở hạ tầng trong cơ sở, trên dịch vụ đám mây hiệu quả, dễ dàng.
  • How to create, validate, and modify the Identity column in Microsoft SQL Server

    microsoft sql server được tích hợp sẵn cột identity, được sử dụng để tạo ra các giá trị quan trọng. nó có thể tham chiếu nhưng một trường autonumber trong microsoft access hoặc một dãy trong oracle. bài viết dưới đây tipsmake sẽ hướng dẫn bạn cách tạo, kiểm tra và thay đổi cột indentity trên microsoft sql server.
  • How to log in to SQL Server if the SA account is disabled.

    trong trường hợp nếu tài khoản sa bị vô hiệu hóa và bạn không thể đăng nhập sql server. bài viết này tipsmake sẽ hướng dẫn bạn cách đăng nhập sql server nếu tài khoản sa bị vô hiệu hóa.
  • Instructions on how to install Laravel, supporting web programming.

    với những ai đang học lập trình không thể nào không biết đến được laravel, vậy làm thế nào để cài đặt laravel trên máy tính của bạn, chạy trơn chu các ứng dụng web cũng như giúp bạn học tập và thực hành tốt.
Category

System

Windows XP

Windows Server 2012

Windows 8

Windows 7

Windows 10

Wifi tips

Virus Removal - Spyware

Speed ​​up the computer

Server

Security solution

Mail Server

LAN - WAN

Ghost - Install Win

Fix computer error

Configure Router Switch

Computer wallpaper

Computer security

Mac OS X

Mac OS System software

Mac OS Security

Mac OS Office application

Mac OS Email Management

Mac OS Data - File

Mac hardware

Hardware

USB - Flash Drive

Speaker headset

Printer

PC hardware

Network equipment

Laptop hardware

Computer components

Advice Computer

Game

PC game

Online game

Mobile Game

Pokemon GO

information

Technology story

Technology comments

Quiz technology

New technology

British talent technology

Attack the network

Artificial intelligence

Technology

Smart watches

Raspberry Pi

Linux

Camera

Basic knowledge

Banking services

SEO tips

Science

Strange story

Space Science

Scientific invention

Science Story

Science photo

Science and technology

Medicine

Health Care

Fun science

Environment

Discover science

Discover nature

Archeology

Life

Travel Experience

Tips

Raise up child

Make up

Life skills

Home Care

Entertainment

DIY Handmade

Cuisine

Christmas

Application

Web Email

Website - Blog

Web browser

Support Download - Upload

Software conversion

Social Network

Simulator software

Online payment

Office information

Music Software

Map and Positioning

Installation - Uninstall

Graphic design

Free - Discount

Email reader

Edit video

Edit photo

Compress and Decompress

Chat, Text, Call

Archive - Share

Electric

Water heater

Washing machine

Television

Machine tool

Fridge

Fans

Air conditioning

Program

Unix and Linux

SQL Server

SQL

Python

Programming C

PHP

NodeJS

MongoDB

jQuery

JavaScript

HTTP

HTML

Git

Database

Data structure and algorithm

CSS and CSS3

C ++

C #

AngularJS

Mobile

Wallpapers and Ringtones

Tricks application

Take and process photos

Storage - Sync

Security and Virus Removal

Personalized

Online Social Network

Map

Manage and edit Video

Data

Chat - Call - Text

Browser and Add-on

Basic setup