SQL Code
SQL Code
SQL Code
-- create database
CREATE DATABASE NITHI;
DROP DATABASE NITHI;
DROP SCHEMA IF EXISTS NITHI;
USE NITHI;
SHOW TABLES;
-- create tables
CREATE TABLE STUDENT(
id int primary key,
name varchar(30),
gpa decimal(3,2)
);
describe student;
-- alter values
alter table student add department varchar(10);
alter table student drop department;
-- insert values
insert into student values(1,"kavya",7.85);
insert into student values(2,"mythu",8.39);
insert into student values(3,"mouni",7.6);
insert into student values(4,"youga",8.2),(5,"nithi",7.65);
insert into student(id,name) values(6,"jai");
select * from student;
select id from student;
select distinct name from student;
select count(distinct name) from student;
-- WHERE ,FILTER
USE NITHI;
SELECT*FROM EMPLOYEE
WHERE NAME LIKE 'A%';
SELECT*FROM EMPLOYEE
WHERE NAME LIKE 'A%A';
SELECT*FROM EMPLOYEE
WHERE NAME LIKE '%I';
SELECT*FROM EMPLOYEE
WHERE NAME LIKE '__I%'; -- I SHOULD BE IN 3RD PLACE
-- \% % IS TAKEN AS A CHAR
-- UPDATE
UPDATE EMPLOYEE
SET JOB ="ANALYST"
WHERE JOB ="ENGINEER";