Sql
SQL Introduction -Create ,Insert ,Update, Delete
SQL Introduction - Create ,Insert ,Update, Delete a Table
Introduction: SQL is a language to store ,manipulate and retrieve data. Okay fine, now what is Data, Data might be anything it is the information . For example if you wanna buy a Dress in online you will open it is online sight to know about it. the information present their in that online website is data. it may be company name or price or sizes anything everything is data. Today i will discuss about 4 important statements every software employee deal with it in his current or previous work place.
1. Create
2. Insert
3. Update
4. Delete
1. Create:
As i explained above in the example to store data we need some space or memory. Microsoft SQL server i will explain in this blog.How to store data in SQL Server. Basically Microsoft SQL Server is a RDBMS Relational Database Management System. Data is stored in the form of tables with columns .
Things to know before creating a table:
its pretty easy first we need to know what we are going to store in that table. Here i will come up with simple example we need to store about a person. so what and all we need to store is nothing but columns of that table. we should be aware and have idea what type of datatype we will store in specific column.
Table Name: Person
Column Names: First Name, Last Name, Age, Address, Mobile ,Email.
You can prefer online editors for learning :
Create Table Person(
FirstName varchar(10),
LastName varchar(10),
Age int,
Address varchar(100),
Mobile varchar(10),
Email varchar(50)
)
Now Table got created we need to insert some data into it.
2. Insert:
Inserting data into table is known as insert. for this important thing to remember is always need to insert the columns in the correct order how you created a table.
it is pretty simple like below.
Syntax:
insert into Person values ('FirstName','Lastname',25, 'Address','Mobile Number','email address')
After insert just write
Select * from Person you can see above image . One table got created with columns in it.
3. Update:
Unfortunately you updated your age 25 it is 28 . in this situation Update will come into picture. we need to update the age from 25 to 28 for Firstname is FirstName person in the table.
Syntax:
update Person set age =28 where FirstName='FirstName'.
4. Delete:
Finally delete this is important command. please make sure to write delete statement with where clause in it otherwise it will delete all records in a table.
Syntax:
Delete from person where age=28
this above statement is to delete the person whose age is 28.
Now i am sure you understood using create, update, insert ,delete and select statements in SQL Server.
Thanks for you time. we always respect your time. Please ask if any queries.
Post a Comment
2 Comments
thanks bro , nice info
ReplyDeleteYou are welcome
Delete