To create an sql database .open SQL Server Management Studio Express.click new query.copy paste the below into that window( first create a database
using create database.then create a table in that using create table
below us the queries for that.)
create database Example
use Example
selct the two lines and click execute query.always select the lines which you want to run ,then only click execute query
now you created a database.next step is to create a table
--1.MemberLogin Table
create table MemberLogin
(
Mid int primary key identity not null,
MName nvarchar(50),
MPassword nvarchar(50),
MType nvarchar(50)
)
--2.Course details Table
create table CourseDetails
(
Cdid int primary key identity not null,
CourseName nvarchar(200),
Duration nvarchar(20),
CourseFee nvarchar(15),
Offer nvarchar(200),
Tax nvarchar(15),
TotalFee nvarchar(15),
LumpSum nvarchar(15),
Instalment nvarchar(15),
CourseType nvarchar(15)
)
select from (--4.MemberLogin Table) to (CourseType nvarchar(15) )) .now click on exicute query.if you click exicute query
without select the line you will get error
now you created the tables
to see the content of these table use select query
select * from Student
select * from CourseDetails
now you can see, there is no data in these table.so we have to use 'insert' command to insert data in to tables
insert into MemberLogin values('Admin','Admin','Admin')
insert into MemberLogin values('renju','renju','Staff')
we don't have to insert mid,becaue it is the primary key.it will incriment automatically.
to see the content of these table use select query again
select * from Student
now you can see datas in this table
now if you want to update the content you can use update query
update MemberLogin set MType='faculty'where mid=2
this will update the mtype of the row which has mid =2
now if you want to delete that row you
delete from MemberLoginwhere sid=2
it will delete the 2nd row
These are the four basic commands of sql.
No comments:
Post a Comment