Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

SQL Basics

Uploaded by

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

SQL Basics

Uploaded by

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

DATA TYPES OF SQL

INT - Whole Numbers


DECIMAL(M,N) - Integer where 'M' is Total no. of digits
and 'N' is no. of digits after decimal
VARCHAR(l) - String of length l
BLOB - Large files like Photos, PDF's,etc
DATE - YYYY-MM-DD
TIMESTAMP - YYYY-MM-DD HH:MM:SS

BASIC SYNTAX TO CREATE A TABLE:

CREATE TABLE <table_name> ( | - SUPPOSE THE TABLE NAME IS


student
student_id INT PRIMARY KEY, | - HERE student_id is the
column head, INT is the data type, PRIMARY KEY means that this column can not have
NULL value and it is unique
name VARCHAR(20), | - HERE name is the column head,
VARCHAR is the data type with length 20
subject VARCHAR(20) | - HERE subject is the column
head, VARCHAR is the data type with length 20
)

TO SEE ALL THE COLUMNS:


DESCRIBE <table_name>

TO DELETE A TABLE:
SYNTAX->
DROP TABLE <table_name>;

TO ADD A COLUMN;
SYNTAX->
ALTER TABLE <table_name> ADD <column_name> <column_dataype>;
FOR EG-
ALTER TABLE student ADD gpa DECIMAL(5,2);

TO DELETE A COLUMN:
SYNTAX->
ALTER TABLE <table_name> DROP COLUMN <column_name>;

TO INSERT DATA:
SYNTAX->
INSERT INTO <table_name> VALUES(<ALL THE VALUES>);
FOR EG-
INSERT INTO student VALUES(1,'Yuv','Mathematics')

TO GET ALL THE DATA:


SYNTAX->
SELECT * FROM <table_name>;

TO UPDATE DATA OF THE ROWS:


SYNTAX->

You might also like