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




Answers were Sorted based on User's Feedback



Answer / parifs

Structured Query Language (SQL) is a language that provides
an interface to relational database systems.

In common usage SQL also encompasses DML (Data Manipulation
Language), for INSERTs, UPDATEs, DELETEs and DDL (Data
Definition Language), used for creating and modifying
tables and other database structures.

Is This Answer Correct ?    151 Yes 21 No

Answer / pavan_1981

sql is a universally accepeted query language whic acts an
interface to the relational databases to fetch,insert and
manipulate the data existing in the database.
sql encompasses of five parts
1.Data Retrieval Language:the commands used to select data
from the database.this includes
a.select
2.Data manipulation Language:commands to manipulate the
data existing in the database.commands in this are
a.insert
b.update
c.delete
d.merge
3.Data Definition Language:commands to define and create
the database ojects like tables ,views etc.commands in this
are
a.create
b.truncate
c.alter
d.drop
e.describe
f.rename
4.Tranaction control Language:the commands in this are
a.grant
b.revoke
5.Data Control Language:the commands in this are
a.Commit
b.Rollback
c.Savepoint.

Is This Answer Correct ?    111 Yes 23 No

Answer / vikranth

sql is a structured query language which acts as an
interface to the RDBMS.It is used in the application
development side to select the data from the database.

DDL is Data definition language statements which are used
to develop a structure to the table. where as DML(data
manipulation language statements) are used to perform the
updations to the data.

Is This Answer Correct ?    77 Yes 33 No




Answer / animesh

SQL IS A STRUCTURED QUERY LANGUAGE THROUGH WHICH WE CAN
COMMUNICATE WITH THE ORACLE SERVER AND SQL STATEMENTS ARE
DIVIDED INTO FIVE STATEMENTS i:e. Data defintion language
(DDL) which is used in creating the tables,views. In DDL
create,
Alter,
Drop,
Rename,
Trucate comes.
where as Data Manipulation Language(DML)command is used to
manipulate the data.In DML
Insert,
Update,
Delete,
Merge.
the third one is Data retrieval i:e. the select command
the fourth one is Transcation control i:e.
commit,Rollback,savepoint.
the fifth one is data control language(DCL) i:e.
grant,revoke

Is This Answer Correct ?    52 Yes 14 No

Answer / g srikanth

1. DML COMMANDS

DML is abbreviation of Data Manipulation Language. It is
used to retrieve, store, modify, delete, insert and update
data in database.

INSERT ROWS
The syntax for this command is

insert into tablename(colname1,colname2) values(value1,value2);

Example:

insert into Student (id, Name) values(1,'Ravi');

This statement is used to insert a row of data into Student
table.

UPDATE ROWS
The syntax for this command is

update tablename set colname1=colvalue where colname2=colvalue;

Example:

update Student set Name = 'Ajay' where id = 2;

This command has updated the Name 'Rose' in Student table
whose id is 2.

SELECT ROWS
This command is used to select rows from a table.The syntax
for this command is

select colname1,colname2 from tablename;

Example:

select Name from Student;

It will display all names from Student table. Like Ravi.

DELETE ROWS
The syntax for this command is-

delete from tablename where [search_conditions];

Example:

delete from Student where id=1;

This statement is used to delete the row from Student table
where the student id is 1.

2. DDL COMMANDS

DDL is abbreviation of Data Definition Language. It is used
to create and modify the structure of database objects in
database.

CREATE TABLE
This statement is used to create a table. The syntax for
this command is

create table tablename (colname1 datatype [constraint],
colname2 datatype [constraint]);

Example:

create table Student (id number(4) primary key, Name
varchar2(20));

It creates the table Student which has two fields id i.e.
Student id and Name i.e. the student name. The number and
varchar2 are the data types of id and Name respectively.
Field 'id' has the size 4 means it can take id up to 4
digits and same for Name, it can take the size up to 20
characters. And also added the constraint Primary key to the
field 'id'.

ALTER TABLE
This command is used to add, drop columns in a table. The
syntax for this command is

alter table tablename add colname1 datatype [constraint];
alter table tablename drop column colname1;

Example:

alter table Student add DOB date;

This command is used to add new field DOB in Student table.
It's datatype is date. This is also used for drop column
from the table. It will drop the DOB field by query given below-

Alter table Student drop column DOB;

DROP TABLE
The syntax for this command is-

drop table tablename;

Example:

drop table Student;

This statement is used for destroy the table from database.

Is This Answer Correct ?    25 Yes 3 No

Answer / 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

Answer / sripathi venkata ramesh

I am Sripathi Venkata Ramesh from Gudivada and the answer
is below here

Data Definition Language: Create, Drop, Modify, Alter,
Truncate

Data Manipulation language: Update, Delete, and
Insert.

Data Control language: Commit, Roll back, save point,
grant/revoke

Is This Answer Correct ?    18 Yes 25 No

Post New Answer



More Oracle General Interview Questions

> 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?

0 Answers  


SQL> CREATE TABLE to_table 2 (col1 NUMBER); Table created. SQL> CREATE OR REPLACE TRIGGER statement_trigger 2 AFTER INSERT ON to_table 3 BEGIN 4 DBMS_OUTPUT.PUT_LINE('After Insert Statement Level'); 5 END; 6 / Trigger created. SQL> CREATE OR REPLACE TRIGGER row_trigger 2 AFTER INSERT ON to_table 3 FOR EACH ROW 4 BEGIN 5 DBMS_OUTPUT.PUT_LINE('After Insert Row Level'); 6 END; 7 / Trigger created. SQL> INSERT INTO TO_TABLE VALUES(1); After Insert Row Level After Insert Statement Level 1 row created. SQL> BEGIN 2 INSERT INTO TO_TABLE VALUES(2); 3 INSERT INTO TO_TABLE VALUES(3); 4 INSERT INTO TO_TABLE VALUES(4); 5 INSERT INTO TO_TABLE VALUES(5); 6 INSERT INTO TO_TABLE VALUES(6); 7 INSERT INTO TO_TABLE VALUES(7); 8 INSERT INTO TO_TABLE VALUES(8); 9 INSERT INTO TO_TABLE VALUES(9); 10 INSERT INTO TO_TABLE VALUES(0); 11 END; 12 / WAT LL BE THE O/P??? XPLAIN IT>>>>

1 Answers   Infosys,


does the query needs a hint to access a materialized view?

0 Answers  


sql query to get zero records from a table

7 Answers   CTS,


waht is referencial integrity?

2 Answers   Semantic Space,






what are views?

7 Answers   TCS,


How to display First 4 rows From Database Table?

6 Answers  


when a grant option is encountered for a table EMP to a peer sitting beside you who has already having the table of that name (EMP), then what is the result?

2 Answers  


pls explain connect by prior with example and its real time use

3 Answers  


We need to compare two successive records of a table based on a field. For example, if the table is CUSTOMER, and the filed is Account_ID, To compare Account_IDs of record1 and record2 of CUSTOMER table, what can be the query ?

3 Answers  


select * from emp what happened internally when we write this query in the sql prompt?

5 Answers  


Explain the concept of the DUAL table.

2 Answers  






Categories