Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
--like operator
select * from student
select * from student where name like
'v%'
select * from student where address like
'%r'
select * from student where name like
'_i%'
select * from student where name like
'____'
select name + ' ' + address as
'name\address' from student
select convert(varchar(5),rollno) + ' '
+ name from student
select *,fees*0.05 as 'tax' from student
--Constraint
--1 primary key
--2 foreign key
--3 unique
--4 check
--1 primary key:
--(1) it does not allow duplicate value
--(2) it does not allow null value
--(3) we can define only one primary key
in a table
create table Author(Authorid int primary
key,Name varchar(20),Address
varchar(20))\
insert into Author
values(4,'Rajesh','Kandivali')
select * from Author
--foreign key:-it accept only
references values from references
table's column
create table book(booid int primary
key,Name varchar(20),Authorid int foreign
key references Author(Authorid),Price
int,pages int)
select * from book
drop table book
insert into book values(106,'Core
java',30,600,510)
create table Dealar(
dealarcode int identity(200,1),
Authorid int foreign key references
Author(Authorid),
Bookid int foreign key references
Book(booid),
dealarname varchar(20),
Address varchar(30)
)
--outer join
--left join
--right join
--full join
--left join returns all data from left
table and only matching data from right
table
select
a.authorid,a.name,a.address,b.Name,b.pric
e,b.pages from Author as a left join
book as b
on a.authorid=b.authorid
--view
select * from book
create view book_view
as
select * from book