DEV Community

Sachin
Sachin

Posted on

Sql basic command 2

we work on the second sql basic command

Delete the table

DELETED FROM

WHERE {Comparision} ORDER BY LIMIT 1;
example-
DELETD FROM Names Where name Like %a& ORDER BY DESC LIMIT 1;

Update the table

UPDATE

SET = value 1 WHERE {Condition};

Changed the Structure the table and add column and before and after col

ALTER TABLE

CHANGED [new constrains (datatype,constraits)]
example - ALTER TABLE Actor ADD Region VARCHAR(10) DEFAULT "Bollywood";
example 2
ALTER TABLE Actors ADD Middlename VARCHAR(10) AFTER FirstName;
exaple 3
ALTER TABLE Actors DROP Middlename;

AS

we discuss the AS IN Sql to used the own name in the column
SELECT DOB AS "Date of Birth" From Actors;

CONCAT

we can merged the Fistname and Lastname
SELECT CONCAT(Fistname,'',Lastname) AS Name FROM Actors;

DISTICT

FIND THE UNIQUE NOT REPEAT
SELECT DISTINCT Score FROM student2;

COUNT

SELECT COUNT(*) As "No of student" From Student2 Where Maritial_Status = "Single"

SUM

SELECT SUM(Score) From Student;


Top comments (0)