Skip to content

01

Initialization

use 20200198db;
set foreign_key_checks = 0;
drop table if exists Students;
set foreign_key_checks  = 1;

Queries

CREATE TABLE Students
(
  ROLL_NO int,
  NAME varchar(20),
  SUBJECT varchar(20)
);
DESC Students;
INSERT INTO Students VALUES (198, "Thahir", "OOPS");
INSERT INTO Students (ROLL_NO, NAME, SUBJECT) VALUES
(198, "Ahmed", "DSA"),
(231, "Ram", "DSA");
SELECT * FROM Students;
SELECT ROLL_NO FROM Students;
SELECT * FROM Students ORDER BY ROLL_NO;
SELECT * FROM Students ORDER BY ROLL_NO desc;
ALTER TABLE Students ADD (AGE int,COUNTRY varchar(40));
ALTER TABLE Students DROP COLUMN AGE;
ALTER TABLE Students MODIFY COUNTRY varchar(20);

alter table table_name drop primary key, add primary key(k1, k2, k3);
DELETE FROM Students WHERE NAME = 'Ram';
DELETE FROM Students WHERE AGE = 20;
DROP TABLE Students;
Last Updated: 2023-01-25 ; Contributors: AhmedThahir

Comments