What is the difference between SQL, DDL, and DML?

Answer Posted / vijitha vijayan

DDL:-
Data definition language.
Mainly 3 commands are available here,create,Drop,Alter.
DML:
•Data manipulating language
•This wil mainly contains select,insert,delete,update operations
DETAILED SYTAX AND EXAMPLES:-
CREATE: SQL CREATE is the command used to create data objects, including everything from new databases and tables to views and stored procedures. In this lesson, we will be taking a closer look at how table creation is executed in the SQL world and offer some examples of the different types of data a SQL table can hold, such as dates, number values, and texts.
CREATE [TEMPORARY] TABLE [table name] ( [column definitions] ) [table parameters]
Ex: CREATE TABLE employees (
id INTEGER PRIMARY KEY,
first name VARCHAR(50) NULL,
last_name VARCHAR(75) NOT NULL,
dateofbirth DATE NULL
);
DROP: - To destroy an existing database, table, index, or view

Drop table tablename;

Ex: DROP TABLE employees;

ALTER: SQL ALTER is the command used to add, edit, and modify data objects like tables, databases, and views. ALTER is the command responsible for making table column adjustments or renaming table columns. New table columns can also be added and dropped from existing SQL tables.

Alter table tablename add tupilname datatype(“range”).

Ex: alter table orders add discount varchar(10);
Alter table orders modify column discount varchar(8,2);
Alter table orders drop column discount ;

•This wil mainly contains select,insert,delete,update operations

SELECT; SQL SELECT may be the most commonly used command by SQL programmers. It is used to extract data from databases and to present data in a user-friendly table called the result set.
•Select table tupile tablename
Ex: select customername from employe;

INSERT: To use the INSERT command, we must first have an understanding of where we would like to insert data and what types of data we want to insert. Do we plan on inserting numbers? Strings? Files? Let's return to the orders table we created in an earlier lesson.
•Insert into tablename(attributename) values(corresponding values that we are like to give)
Ex: Insert into employe (custname) value(“vijitha”);

DELETE: In the SQL world, databases, rows, and columns all have one thing in common: once a DELETE statement has been executed successfully against them, the data they once contained is lost forever! Be very careful with these commands and be sure to properly backup all data before proceeding with any type of DELETE command(s).

Delete from tablename where[include the condition];
Ex: Delete from employe where custname=vijitha;

UPDATE: SQL UPDATE is the command used to update existing table rows with new data values. UPDATE is a very powerful command in the SQL world. It has the ability to update every single row in a database with the execution of only a single query. Due to UPDATE's supreme authority, it is in your best interest to always include a WHERE clause when working with UPDATE query statements. That way, you will not accidentally update more rows than you intend to.
Udate tablename set any condition where any condition;
Ex: update orders set custname=’amith’ where age=’20’;

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I decide when to use right joins/left joins or inner joins or how to determine which table is on which side?

534


How to import one table back from a dump file?

580


Explain oracle left join with an example?

572


What is the difference between pre-select and pre-query?

611


What is the dynamic sql in oracle?

581






> CREATE OR REPLACE FUNCTION FACTORIAL_1(factstr varchar2 ) 2 RETURN NUMBER AS 3 new_str VARCHAR2(4000) := factstr||'*' ; 4 fact number := 1 ; 5 BEGIN 6 7 WHILE new_str IS NOT NULL 8 LOOP 9 fact := fact * TO_NUMBER(SUBSTR(new_str,1,INSTR(new_str,'*')-1)); 10 new_str := substr( new_str,INSTR(new_str,'*')+1); 11 END LOOP; 12 13 RETURN fact; 14 15 END; explanation Above program?

1559


How to drop an index in oracle?

594


Why packages are used in oracle?

531


How to add a new column to an existing table in oracle?

576


What is a relational database management system?

660


How to unlock the sample user account in oracle?

550


What is an index associated with a constraint?

541


Can group functions be mixed with non-group selection fields?

522


What is the simplest tool to run commands on oracle servers?

502


Difference between pre-select and pre-query

563