Header Ads

SQL Commands

sql training

SQL All Commands


SQL TRAINING - USING ALL COMMANDS


We are telling all SQL commands. As a result, you can have basic knowledge about SQL and database queries.

We will touch on creating tables, querying data, adding data to tables, mathematical operations, column concatenation, and other SQL topics.

--   Used to add comment lines.

CREATING A NEW SQL DATABASE

create database ... (You must enter the name of the database you want to create in the dotted area.)

CREATE SQL TABLE

create table ...  (You should write your own table name in the dotted area.)

For Example;

create table School (                 --Table Name
StudentNumber varchar (4),      --Column name (Our data type varchar)
StudentName varchar (12),        --Column name (Our data type varchar)
StudentSurname varchar (20))   --Column name (Our data type varchar)

When we create our table we open the parentheses and insert the columns into the parentheses. We need to specify the data type of each column. We have to put a comma after each column.

ADDING A NEW COLUMN TO THE CONSTRUCTED TABLE

We use the alter command to add a new column to the table we created.

For Example;

alter table School add StudentNote varchar(50)

If you want to add more than one field, we put a comma in it.

TO CHANGE A FIELD

alter table ... alter column ... smallint (You can specify the type of data you want.)

For Example;

alter table School alter column Note smallint

DELETE TABLE

The drop command is used to delete the table.

drop table ... (You must enter the table name in the dotted area.)

COLUMN DELETION

alter table ...(Here's the table name.)  drop column ... (Here's the column name.)

For Example;

alter table School drop column Note

DELETE INFORMATION IN TABLON

The truncate command is used to delete the data without deleting the table.

truncate table ... (Here's the table name.)

For Example;

truncate table School

No comments

Powered by Blogger.