Databasequestion
Databasequestion
DDL Represents "Data Definition Language." DDL is a language used to describe data
formation and data conversion. For example, DDL commands can be used to add,
delete, or modify tables within a database. DDLs used in database applications are
considered as a subset of SQL, Structured Query Language. However, DDL can also
define other types of data, such as XML.
Data Definition Language has a pre-defined syntax for interpreting data. For
example, to create a new table using SQL syntax, the CREATE command is applied,
followed by table name parameters and column descriptions. DDL can also define the
name of each column and the corresponding data type. Once the table is set, it can
be converted using the ALTER command. If a table is no longer needed, a DROP
command can be used to clear the table.
The general syntax for create command in Data Definition Language is mentioned
below:
Generally, the data types often used consists of strings and dates while creating a
table. Every system varies in how to specify the data type.
An existing database object can be modified by the ALTER statement. Using this
command, the users can add up some additional column and drop existing columns.
Additionally, the data type of columns involved in a database table can be changed
by the ALTER command.
Pupil ID PUPIL_Name
97 Albert
98 Sameer
After Adding Column
By the use of this command, the users can delete the database, table or view. A
component from a relational database management system can be removed by a DROP
statement in SQL. There are many systems that allow the DROP and some other Data
Definition Language commands for occurring inside a transaction and then it can be
rolled back.
The object will not be available for use once the DROP statement executed
If you want to delete a table then its syntax and example will be like this
4. Rename
Changing the name of a table, view, sequence, or private dictionary uses a POSSIBLE
statement.
syntax:
5.TAKING TABLE
while creating a TRUNCATE TABLE database it automatically moves all the space used
by the deleted lines.
Question 2:
DML stands for Data Manipulation Language which basically deals with the
modification of data in the database. DML statements include structured query
statements like select, insert, update, delete, etc. The manipulation of data
includes following operations like storing, modifying, retrieving, deleting, and
updating data in a database.
The SQL commands that deals with the manipulation of data present in the database
belong to DML or Data Manipulation Language and this includes most of the SQL
statements.
Examples of DML:
. INSERT
It is used to insert or add new rows or records in the existing table.
Syntax:
Where,
table name: The name of the table In which the data needs to be inserted.
values: values for each column of the table.
To insert values in the table we first need to create a table which is a DDL(Data
definition language) statement. Here, in the below all the examples we have created
a table named students. we will show a demonstration of the DML statement in this
table only. So, let’s start with creating the students table.
We can also populate one table using another table with the help of select
statement. The only condition is that the table must have the same sets of
attributes.
Insert into table_no_first [(column1, column 2…column n)] select column1, column 2…
column n from table_no_two [where condition];
2. SELECT
It used to display the contents of the tables. It is also used to select data from
the database. Below is the syntax to select specified columns and records from the
table.
Below is the query of selecting all records and columns from table:
Syntax:
3. Update
It is used to change the existing values of the column i.e, changing the name of
the student or changing the course of any student.
Syntax of update statement:
4. Delete
Delete statement is used to delete rows of the table based on the specified
conditions.
Syntax:
table_name: Name of the table from which the data needs to be deleted.
condition: Condition based on which the data is to be deleted.
select * from students;
The above example tells that, when delete command is performed on table students
and wants to delete students_name=’aman’, then it deletes the entire details of
‘aman’ and gives the output of remaining students in the table. Here, one by one we
have deleted all the rows of the table. In the end, the table is only left with the
column’s name and its schema. To delete the schema we have to use a DROP statement
which is a DDL statement.