SQL Interview Questions:

 SQL Interview Questions:
sql interview questions:
1).What is sql?
2).what are the subsets of sql?
ddl -dattruncatea definitaion laungade = create ,alter,drop,
dml
dcl
tcl

---------------------
1).create the database :
insert,update,delete,select sql for beginners :

1).how to create the table?
2).How to insert the values and rows into the tables?
3).How to update the table into sql?
for example am entring the john age is wrong. so i need to chnage the 25 . so for that situvation we have to use the upadte command into sql .
so , we can execute the command like as the,
update student  set  age =23 where name='john';
 
4).How to delete the rows from the paticular tables and delete the compeplete table?
------------------------------------------------------
1).How to create the customer table into sql databases?
1)sql practice questions?

1).How to create the customer table into sql?
create table customer (customer_id varchar(200),customer_name varchar(200),customer_address varchar(100),city varchar(200),state varchar(100));


select * from customer;
alter table  customer add zip_code varchar(255);
select * from customer;
2).How to you insert columns for below tables into sql?
insert into customer (customer_id,customer_name,customer_address,city,state,zip_code)
values ('1','johndoe','392 sunset blvd','newyork','NT','10059');
insert into customer(customer_id,customer_name,customer_address,city,state,zip_code)
values ('2','mary smith','6900 main st','san fransico','CA','94032');

insert into customer(customer_id,customer_name,customer_address,city,state,zip_code)
values ('3','richard newman','2024 riverside rd','san diego','CA','92010');
insert into customer(customer_id,customer_name,customer_address,city,state,zip_code)
values ('4','cathy cook','4010 speedway','tucson','AZ','85719');

select * from customer;

3).How can we chnage the customer_address column to just 'address'?
alter table customer change column customer_addfres address varchar(255);
4)How do you add a new column called mobile_numver?

alter table customer add mobile_number varchar(255);
select * from customer;

5).How do you delete a column where mobile_number is null?
if you want to delete the null column from a tables 
so we can execute the command like as the,

delete from table_name where mobile_number is ull
delete from customer where mobile_number='NULL';
select * from customer;
delete from customer where mobile_number is null;

6).How do you insert below records into table?
insert into customer (customer_id,customer_name,customer_address,city,state,zip_code,mobile_number)
values ('1','johndoe','392 sunset blvd','newyork','NT','10059','345678090');
insert into customer(customer_id,customer_name,customer_address,city,state,zip_code,mobile_number)
values ('2','mary smith','6900 main st','san fransico','CA','94032','8344521875');

insert into customer(customer_id,customer_name,customer_address,city,state,zip_code,mobile_number)
values ('3','richard newman','2024 riverside rd','san diego','CA','92010','6383164989');
insert into customer(customer_id,customer_name,customer_address,city,state,zip_code,mobile_number)
values ('4','cathy cook','4010 speedway','tucson','AZ','85719','456789234');
select * from customer;


7).How to show the all records :

select * from table_name;
8).How to view the partlcat cilumn from table?
select customer_name,city from customer;

9).How can you update the phone number for mary smith to 6383164989

update customer set mobile_number='67890' where customer_name = 'mary smith';

select * from customer;


10).How can you delete the record where the zip_code is "600601"?
select * from customer;

delete from customer where zip_code ='10059';

select * from customer;

11).How can you select distinct data where the user is from a state = "ca"?
select * from customer;
select * from customer where state = 'ca';
select * from customer where state = 'ca';


12).How do you print customer id's who are greater than 5?
select * from customer where customer_id>5;

13).How do you delete the mobile number column?
delete from 

alter table customer drop column mobile_number;
select * from customer;



select * from student;



select sum(student_mark) from student;


select max(student_mark) from student;


select min(student_mark) from student;

select count(*) from student;


select * from student;


select avg(student_mark) from student;


select count(student_name) from student where department='cse';


select count(student_name) from student where student_mark='1';










Comments

Popular posts from this blog

Linux interview Questions :

AWs Interview Questions