0% found this document useful (0 votes)
79 views3 pages

SQL Commands

The attachments include 1. Class 10 IT notes 2. Class 9 Science mindmap 3. Class 10 Computer Application Practical File 4. Class 10 IT SQL Commands 5. Class 9 Spreadsheet Projects

Uploaded by

Sheikh Abdullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views3 pages

SQL Commands

The attachments include 1. Class 10 IT notes 2. Class 9 Science mindmap 3. Class 10 Computer Application Practical File 4. Class 10 IT SQL Commands 5. Class 9 Spreadsheet Projects

Uploaded by

Sheikh Abdullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

IT 402 | APS 2024

SQL COMMANDS through fishTable


1. Create the fishTable
CREATE TABLE fishTable (
sn INT PRIMARY KEY,
name VARCHAR(30),
seedDt DATE,
feedQty DECIMAL(6,2),
taste CHAR(1)
);

2. Add Four Rows of Imaginary Fish Data


INSERT INTO fishTable (sn, name, seedDt, feedQty, taste) VALUES
(1, “Goldfish”, “2023-01-01”, 15.50, “A”),
(2, “Betta”, “2023-02-01”, 10.00, “B”),
(3, “Guppy”, “2023-03-01”, 12.25, “A”),
(4, “Tetra”, “2023-04-01”, 14.75, “C”);

3. Display All Fields in Table


SELECT * FROM fishTable;

4. Delete a Record (Various Ways)


-- Delete using primary key
DELETE FROM fishTable WHERE sn = 2;

Page 1 of 3
IT 402 | APS 2024

-- Delete using name


DELETE FROM fishTable WHERE name = “Guppy”;

5. Single Line and Multi-Line Comment


-- This is a single-line comment
/* This is a
multi-line comment */

6. Update Data
UPDATE fishTable
SET feedQty = 20.00
WHERE name = “Goldfish”;

7. Organize Data by a Particular Field


-- Ascending order by feedQty
SELECT * FROM fishTable ORDER BY feedQty ASC;

Page 2 of 3
IT 402 | APS 2024
-- Descending order by feedQty
SELECT * FROM fishTable ORDER BY feedQty DESC;

8. Alter the fishTable


ALTER TABLE fishTable
ADD color VARCHAR(15) DEFAULT 'Unknown';

-- Drop a column
ALTER TABLE fishTable DROP COLUMN color;

9. Display Only Selected Fields


SELECT name, feedQty FROM fishTable;

10. Delete fishTable


DROP TABLE fishTable;

11. DDL Vs DML


Aspects DML (Data Manipulation Language) DDL (Data Definition Language)
Definition DML commands are used to manipulate DDL commands are used to define and
and manage data in a database. manage the structure of a database.
Examples INSERT, UPDATE, DELETE, SELECT CREATE, ALTER, DROP, DELETE, TRUNCATE
Note that SQL keywords written in uppercase are NOT CASE-SENSITIVE.

Page 3 of 3

You might also like