Code Monkey home page Code Monkey logo

dbms-ex03's Introduction

Dbms-ex03 - DML COMMANDS-UPDATE,DELETE,SELECT

DATE: 19-03-24

REGISTER NUMBER:212222040005

AIM:

To Study and write DML Commands for given query.

THEORY:

DML(Data Manipulation Language)

  • The SQL commands that deal with the manipulation of data present in the database belong to DML or Data Manipulation Language and this includes most of the SQL statements.
  • It is the component of the SQL statement that controls access to data and to the database. Basically, DCL statements are grouped with DML statements.

List of DML commands:

  1. INSERT: It is used to insert data into a table Types of INSERT COMMAND a) Inserting a single record Syntax: INSERT INTO < relation/table name> (field_1,field_2……field_n)VALUES (data_1,data_2, ...... data_n); b) Inserting all records from another relation Syntax: INSERT INTO relation_name_1 SELECT Field_1,field_2,field_n FROM relation_name_2 WHERE field_x=data; c) Inserting multiple records Syntax: INSERT INTO relation_name field_1,field_2, ....field_n) VALUES (&data_1,&data_2,.......&data_n);
  2. UPDATE: It is used to update existing data within a table. Syntax: UPDATE relation name SET Field_name1=data,field_name2=data, WHERE field_name=data;
  3. DELETE: It is used to delete records from a database table. a) DELETE-FROM: This is used to delete all the records of relation. Syntax DELETE FROM relation_name; b) DELETE -FROM-WHERE: This is used to delete a selected record from a relation. Syntax: DELETE FROM relation_name WHERE condition;
  4. SELECT: The SELECT command shows the records of the specified table. Syntax: SELECT (column1,column2) FROM (Table Name)WHERE condition;

PROCEDURE:

  1. Start the program.
  2. Read the given query.
  3. insert values into the table using INSERT INTO < relation/table name> (field_1,field_2……field_n)VALUES (data_1,data_2, ...... data_n);
  4. Update the existing data within a table by UPDATE command by UPDATE relation name SET Field_name1=data,field_name2=data, WHERE field_name=data;
  5. Delete the records in a table by DELETE command DELETE FROM relation_name WHERE condition;
  6. Use SELECT command shows the records of the specified table. SELECT (column1,column2) FROM (Table Name)WHERE condition;
  7. Show the output
  8. Stop the program

QUERY:

QUERY 1

image

SQL QUERY

select categoryName,description from categories order by categoryName;

TEST QUERY AND ITS OUTPUT

image

QUERY 2

image

SQL QUERY

SELECT * FROM customer WHERE city = 'London' AND grade > 200;

TEST QUERY AND ITS OUTPUT

image

QUERY 3

image

SQL QUERY

SELECT * FROM orders WHERE (purch_amt < 200 OR NOT (ord_date >= '2012-02-10' AND customer_id < 3009));

TEST QUERY AND ITS OUTPUT

image

QUERY 4

image

SQL QUERY

SELECT * FROM customer WHERE grade IS NULL;

TEST QUERY AND ITS OUTPUT

image

QUERY 5

image

SQL QUERY

DELETE FROM surgeries WHERE surgery_id = 3 or surgeon_id = 4;

TEST QUERY AND ITS OUTPUT

image

QUERY 6

image

SQL QUERY

DELETE FROM customer WHERE OPENING_AMT BETWEEN 4000 AND 6000;

TEST QUERY AND ITS OUTPUT

image

QUERY 7

image

SQL QUERY

DELETE FROM customer WHERE LENGTH(CUST_NAME) = 6;

TEST QUERY AND ITS OUTPUT

image

QUERY 8

image

SQL QUERY

UPDATE products SET product_name = 'Grapefruit' WHERE product_id = 4;

TEST QUERY AND ITS OUTPUT

image

QUERY 9

image

SQL QUERY

UPDATE suppliers SET supplier_name = 'A1 Suppliers' WHERE supplier_id = 8;

TEST QUERY AND ITS OUTPUT

image

QUERY 10

image

SQL QUERY

UPDATE products SET reorder_lvl = 40 WHERE category = 'Grocery';

TEST QUERY AND ITS OUTPUT

image

RESULT :

Thus the basic DML commands are executed.

dbms-ex03's People

Contributors

akshayalakshmivs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.