create database dummy;
use dummy;
create table customer (customer_name varchar(255),customer_id int, customer_address int , city varchar(255),state varchar(255),zip_code int);
select * from customer;
insert into customer (customer_name,customer_id,customer_address,city,state,zip_code)
values ('nandhini','10','234','covai','tamil nadu','10052')
create database dummy1
use dummy1;
create table dummy1 (customer_name varchar(255),customer_id int, customer_address varchar(255), city varchar(255),state varchar(255),zip_code varchar(255));
insert into dummy1 (customer_name,customer_id,customer_address,city,state,zip_code)
values ('nandhini','10','234 sunset vaddkku','covai','tamil nadu','10052');
insert into dummy1 (customer_name,customer_id,customer_address,city,state,zip_code)
values ('mary','23','456 main street ','san fansico ','ca','78900');
insert into dummy1 (customer_name,customer_id,customer_address,city,state,zip_code)
values ('cathy cook','4','4010 speed way ','tuck son','az','649080');
insert into dummy1 (customer_name,customer_id,customer_address,city,state,zip_code)
values ('richard newman','3','2040 riverside rd ','san diego ','ca','92010');
select * from dummy1;
alter table dummy1 change column customer_address address varchar(200)
alter table dummy1 add column mobile_number varchar(255)
delete from dummy1 where customer_id = 23;
select * from dummy1;
alter table dummy1 add column_name mob_number varchar(100);
select * from dummy1;
use dummy;
select customer_name from dummy1;
update dummy1 set mobile_number="82206-1234" where customer_name = "nandhini";
alter table dummy1 add phone_number varchar(255);
alter table dummy1 change column customer_id customer_rollno varchar(255);
update dummy1 set phone_number='82206-1234' where customer_name='mary';
delete from dummy1 where customer_id='1';
select * from dummy1;
update dummy1 set phone_number='234567890' where customer_name ='cathy cook';
delete from dummy1 where zip_code='78900';
select * from dummy1 where state='ca';
select * from dummy1 where customer_id>5;
alter table dummy1 drop column phone_number;
truncate table dummy1;
alter table dummy1 add gifts varchar(255);
1).How do you make the table in sql?(for the customer):
2)..How do you insert below records into sql?
3).How can we change the customer_adddress column to address?
alter table table name change column customer_adddress address varchar(200)
4).how do you add a new column mobile number?
alter table table name mobile number int;
5).how do you delete a column from a table ?
delete * from table-bae where
6).How do you insert below records?
7).how to show the all records into table?
select * form table name
8).how can view the particular column from table?
we can execute the command like as the,
select customer_name,customer_id from table_namel
9).How can you update the phonenumuber for 'mary smith to '82206-1234'?
update dummy1 set mobile number="82260-1234" where customer name = "";
10).how can you delete the record where the zip code is "606778"
delete from dummy1 where zip code='":
11).how can you select distinct data where the user is from a state ="ca"?
select * from dummy1 where state="ca"
12).how do you print customer IDs who are greater then 5?
select * from table_name where customer_id >5;
13).How do you delete the mobile number column?
alter table table_name drop column phone_number:
14).How do you trucate table ?
--------------------------------------------------------
aggregate functions:
1).sum()create database dummy0;
use dummy0;
create table student (student_name varchar(255),student_mark int,department varchar(255))
insert into student (student_name,student_mark,department)
values ('nandhini','1','it');
insert into student (student_name,student_mark,department)
values ('ram','2','cse');
insert into student (student_name,student_mark,department)
values ('ragu','3','mech');
insert into student (student_name,student_mark,department)
values ('raghul','4','ece');
select * from student;
select student_mark from student;
select sum(student_mark) as totalmark from student;
select max(student_mark) from student;
select min(student_mark) from student;
select avg(student_mark) from student;
select * from student;
select * from student where student_mark='2';
select count(student_name) from student;
select count(student_name) from student where department='cse';
1).how do you get student total mark in sql table?
select sum(stduent_mark) from student;
select sum(student_mark) as totalmark from table_name;
2).which student are getting most highest mark?
select max(student_mark)f from table_name;
3).How to get lowest mark from student table?
select min(student_mark) from table_name
4).how to get average mark from student_table?
select avg(student_name) from table_name
'
Comments
Post a Comment