Arrow

SQL Table

AuthorHariom Prajapati

Pubish Date03 Jul 2022

categoryMySql

1) SQL - Create a table

To create a table in the selected database.

 

Syntax -

create table table_name (
column1 datatype(range),
column2 datatype(range),
column3 datatype(range),
   ....
);

sql create a table

 

2) SQL - Show tables

To show all tables in the selected database.

 

Syntax -

show tables;

sql show table

 

3) SQL -Describe table name

To show detail about any table in selected database like number of fields, key, extra (auto-increment), data type, null etc.

 

Syntax -

desc table_name ;

sql describe table name

 

4) SQL - Delete a table

To delete a table in the selected database.

 

Syntax -

drop table  table_name ;

sql delete a table

 

5) SQL- Insert data into a table

To insert data in a table.

 

Syntax -

insert into table_name ( coloumn1_name, coloumn2_name, coloumn3_name, ………….. ) ;
values ( coloumn1_value, coloumn2_value, coloumn3_value, ……….);

sql inser data into a table

 

Note:- varchar value must be in the ‘…..’  or   “…..” when inserting data.

OR

We can also insert value by below code

Syntax -

insert into table_name;
values ( coloumn1_value, coloumn2_value, coloumn3_value, ……….);

sql insert data into a table

 

6) SQL - Show data of table

To show inserted data in the table which we created in the database.

 

Syntax -

select * from table_name ;

sql show data of table

 

7) SQL- Add column in a table

Using this, we can add a column in any table.

 

Syntax -

alter table table_name add column_name data_type(range) ;

sql add a column from table

 

8) SQL - Delete a column from the table

Using this we can delete any column from a table.

 

Syntax -

alter table table_name drop column column_name;

sql delete a column from table