TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Basics of DML in SQL
Burak Seyhan
Feb 03
2015
Code
1.2
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
use Master
/*
Basics
of
Data Manupulation Languages
*/
Create
Database
DemoByBurakSeyhan
go
use DemoByBurakSeyhan
go
Create
Table
Customer
(
Id
int
primary
key
identity(1,1),
InsertedTime datetime
default
getdate(),
DeletedTime datetime
null
,
FirstName nvarchar(25)
not
null
,
MiddleName nvarchar(25)
null
,
LastName nvarchar(25)
not
null
,
Age
int
not
null
,
Gender nvarchar(2)
not
null
,
BirthDate datetime
not
null
)
go
/*
DML (Data Manupulation Language) Statement
Insert
,
Update
,
Delete
,
Select
*/
-- First One is Insert
Insert
Into
Customer(FirstName,MiddleName,LastName,Age,Gender,BirthDate)
Values
(
'Burak'
,
'-'
,
'Seyhan'
,24,
'M'
,
'1996-07-19 00:00:00.000'
)
--Default is insert you dont need a into keyword
Insert
Customer(FirstName,MiddleName,LastName,Age,Gender,BirthDate)
Values
(
'Burak'
,
'-'
,
'Seyhan'
,24,
'M'
,
'1996-07-19 00:00:00.000'
)
go
-- Select all customers
Select
*
from
Customer
go
-- Second one ise Update
Update
Customer
set
FirstName =
'Bob'
, MiddleName=
'Jack'
, LastName=
'Smith'
Where
Id = 4
--then show new data
Select
*
from
Customer
go
-- Third one is Delete
Delete
from
Customer
-- This code is a dangerous casue you didn't use Where keyword.
-- I Think the best security is
Delete
from
Customer
Where
Id = 4
--then show all data from database
Select
*
from
Customer
DML
SQL