0% found this document useful (0 votes)
247 views

CRUD - Fundamentals of SQL Operation

The document discusses the CRUD fundamentals of SQL operations. CRUD stands for Create, Read, Update, and Delete. It provides examples of SQL statements to: - CREATE databases and tables using CREATE DATABASE and CREATE TABLE statements. - READ and SELECT data from tables using SELECT statements. - UPDATE table data using UPDATE statements with a WHERE clause to target specific records. - DELETE rows from tables using DELETE statements with a WHERE clause to specify which records to delete.

Uploaded by

testuser
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
247 views

CRUD - Fundamentals of SQL Operation

The document discusses the CRUD fundamentals of SQL operations. CRUD stands for Create, Read, Update, and Delete. It provides examples of SQL statements to: - CREATE databases and tables using CREATE DATABASE and CREATE TABLE statements. - READ and SELECT data from tables using SELECT statements. - UPDATE table data using UPDATE statements with a WHERE clause to target specific records. - DELETE rows from tables using DELETE statements with a WHERE clause to specify which records to delete.

Uploaded by

testuser
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

CRUD – Fundamentals of SQL Operation

C CREATE / INSERT

R READ / SELECT

U UPDATE

D DELETE
CREATE
/*Creating Database*/
CREATE DATABASE databasename;

/*Creating Table*/
CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,
    column3 datatype,
   ....
);
CREATE

/*Creating Table* FROM another table/

CREATE TABLE new_table


AS (SELECT * FROM old_table);
INSERT
/*Specifying Columns*/
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

/*All Columns*/
INSERT INTO table_name VALUES
(value1, value2, value3, ……);

/*From another table*/


INSERT INTO table_name1
SELECT * FROM table_name2
Consider the following code written
for creating the table:
A. BALANCE must be NOT NULL
CREATE TABLE ACCOUNT B. ACCNO must be NOT NULL
(ACCNO INT , ACCNAME C. Primary key is missing for
VARCHAR(30) NOT NULL,BALANCE ); ACCOUNT
D. BALANCE must have a datatype

The table is NOT getting created,


identify the reason.
READ/SELECT
SELECT column1, column2, ...
FROM table_name;

SELECT * FROM table_name;

SELECT DISTINCT column1, column2, ...
FROM table_name;
Which of the following statement contains an error ?

A. Select * from employee where empid = 10003;


B. Select empid from employee where empid = 10006;
C. Select empid from employee;
D. Select empid where empid = 1009 and last name = ‘Jones';
UPDATE
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

WHERE clause is very important

Be careful when updating records. If you omit the WHERE clause, ALL
records will be updated!
DELETE
DELETE FROM table_name WHERE condition;
Which of the following SQL
Statement is used to remove rows
from a table.

A. DROP
B. REMOVE ROW
C. DELETE
D. DELETE ROW
Which of the following SQL
Statement is used to remove rows
from a table.

A. DROP
B. REMOVE ROW
C. DELETE
D. DELETE ROW
THANK YOU!

You might also like