SQL Queries

create database sampleDB;

use sampleDB;


drop database sampleDB;


create database sampleDB;


use sampleDB;


create table customers(

id int not null,

name varchar(20) not null,

age int not null,

city varchar(25),

salary decimal(18,2),

primary key(id)

);


desc customers;


insert into customers values

(1,'Sandhya',22,'mpl',null),

(2,'sravani',26,'mpl',20000),

(3,'pooji',23,'bangalore',null),

(4,'vyshu',23,'kadapa',25000),

(5,'lalitha',23,'mpl',null),

(6,'gowthami',23,'vayalpadu',17000),

(7,'renu',24,'mpl',null),

(8,'siri',23,'gorintla',18000);


select * from customers;


update customers set salary=18000 where id=7;


update customers set salary=25000 where id=1 or id=5;


alter table customers add gender char(1);


desc customers;


update customers set gender='f' where id in(1,2,3,4,5,6,7,8);


select distinct salary 

from customers

where salary is not null

order by salary;


create unique index sample_index on customers(id);


Comments

Popular posts from this blog

SQL Queries

SQL Queries

SQL Queries