0% found this document useful (0 votes)
16 views

Create Database Use Create Int Varchar: SQL0911 SQL0911 Student Id Name 30

This document provides instructions on how to perform various SQL operations like creating a database and table, inserting records, selecting records with filters and conditions, customizing output, concatenating values, and using comparison operators. It shows how to create a database called SQL0911, create a table called Student with two columns - id and name, insert sample records, select specific columns or records based on filters, customize column names and values for output, concatenate strings, calculate new columns, and use comparison operators like between, in, like for filtering records.

Uploaded by

navdeep_sidana
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Create Database Use Create Int Varchar: SQL0911 SQL0911 Student Id Name 30

This document provides instructions on how to perform various SQL operations like creating a database and table, inserting records, selecting records with filters and conditions, customizing output, concatenating values, and using comparison operators. It shows how to create a database called SQL0911, create a table called Student with two columns - id and name, insert sample records, select specific columns or records based on filters, customize column names and values for output, concatenate strings, calculate new columns, and use comparison operators like between, in, like for filtering records.

Uploaded by

navdeep_sidana
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Notes

How to create a new database.


create database SQL0911
How to activate the database.
use SQL0911
How to create a table in SQL.
create table Student (id int ,name
varchar(30))
Above command will create a table with a name
Student with 2 columnsid and name.
How to see the table created.
select * from student
Above command will show u empty table.
Asterick(*) means it will fetch all
columns.
How to insert a record in a table.
insert into student values
(12,'Felicien')
insert into student values
(1,'Kanchan')

insert into student values


(3,'Navdeep')
insert into student values (6,'Raman')
insert into student values (10,'Banza')
Execute select command to see the
table and press f5.
How to fetch a particular record from a
table.(suppose u want fetch the row
which has is 3).
select * from student
where id=3
Above command will fetch 1 record.
We have set the criteria using where
clause.
How to fetch particular column from a
table.
select name from student
Above command will fetch only 1 column.

Customizing the display :

Customizing the display means for


display purpose we are changing the
name of the columns.It will not change
the name of the column permamently in
our database.
select 'StudentID'=id,'Student
Name'=name
from student

Literal
select id ,' id has name',name from
student
Concantenation :
select 'Hello '+' Good Morning'
concantenate joins 2 strings.
Follow the below commands :
create table Product (name
varchar(50),descp varchar(50))

insert into product values


('pen','stationary')
insert into product values
('pencil','stationary')
insert into product values
('Speakers','computer')
insert into product values
cover','phone')

('Back

select * from product


select name +' has a ' + descp from
product
Above command use concatenation with
literals.
select name +' has a ' + descp
'ConcatCol'
from product
--Giving a name to the column.
Calculating column values :
select id,name,id * 2 as
'CalculatedCol'
from student
Comparison operator
select * from student

as

where id < 6
Logical operator
select * from student
where id = 6 or id =12
select * from student
where id = 100 and name='Banza'
Range operator
select * from student
where id between 1 and 6
select * from student
where id not between 1 and 6

In Keyword
select * from student
where name
in('Banza','Dhruv','Kanchan')
select * from student

where name not


in('Banza','Dhruv','Kanchan')
Like Keyword
insert into product values
('peg','electronic')
select * from product
where name like '%s'
select * from product
where name like 'p%'
select * from product
where name like 'pe_'

You might also like