Tuesday, 24 March 2020

Most Important SQL Commands

3/24/2020 - By Pranav Singh 0


This article will show you the most common or important or most common sql command. This will be helpful for the beginners sql developers.


So in this we will cover following points:
  •          Create New Database
  •          Alter Database
  •          Create New Table
  •          Insert Record
  •          Select Record
  •          Update Record
  •         Delete Record
  •          Truncate Record
Create New Database: In this will see how we can create a new data base by using sql query.

Syntax:
Create database <databasename>;

Example:
Create database TestDataBase;


 Now check the data base.



• Alter Database: In this we ill check how we can alter the database name in sql.

Syntax:
ALTER DATABASE <OldDataBaseName>
Modify Name = <NewDataBaseName> ;

Example:
ALTER DATABASE TestDataBase
Modify Name = TestDataBaseModified ;

Here when you run the above query.



Finally, here is the output with modified data base name.


• Create New Table: In this section we will see how we can create a table in sql server.

Syntax:
CREATE TABLE tablename (
    Column1 datatype,
    Column2 datatype,
    Column3 datatype,
       .
       .
        Columnn datatype
);

Example:
CREATE TABLE TestTable (
    Id int,
    Name varchar(50),
    Address varchar(100)
);

Now run the query and check


Now check the database weather the table is created or not.



• Insert Record: In this we ill check how we can insert data int table.

Syntax:
INSERT INTO tablename
VALUES (value1, value2, value3, ...,valueN);

Example:
INSERT INTO TestTable
           (Id
           ,Name
           ,Address)
     VALUES
           (1,
           'aspdotnetpoolss.com',
           'internaet');

Now check the table for output.


• Select Record: In this we will cover how we can access the data present into the database table.

Syntax:
SELECT Coumn1,
      ,Colum2
      ,Cloumn3
         .
         .
         .
         ColumnN
  FROM TestTable

Example:
SELECT Id
      ,Name
      ,Address
  FROM TestTable

Now run the query and check the output.


• Update Record: In this we learn how we can update the record of a table.

Syntax:
Update TableName Set Column1=value1, Column2=value2,....ColumnN=valueN Where condation=Value;

Example:
UPDATE TestTable
   SET  Address = 'InterNetAddress'
 WHERE Id=1;

Now run and check the output.

• Delete Record: In this we will check how we can delete the record from the database

Syntax:
Delete from TableName Where Condation=value;

Example:
Delete All
Delete from TestTable

Conditional delete
Delete from TestTable Where Id=1

Run the above query and check the output.


  Truncate Record: Truncate table us used for removing all the detail from the database table.
Syntax:
Truncate Table TableName;

Example:
Truncate Table TestTable;
Run the above query and check the query.


Tags:
About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top