Download MySQL : DDL and DML In SQL – Rull Full Version

welcome to wowaze site, you are on page MySQL : DDL and DML In SQL – Rull
Published on 2020-06-04 16:39:00 please download your needs here, and don’t forget to follow us by bookmarking this site.

You’re looking for #MySQL #DDL #DML #SQL #Rull And are in the right place because we have prepared for you, please enjoy.

DDL or Data Definition Language is a command in SQL related to defining a database structure. DDL Has functions to do the following:

  1. CREATE DATABASE and DROP DATABASE to Create/delete database
  2. CREATE TABLE and DROP TABLE to Create/delete tables
  3. ALTER TABLE to Modify table

Displaying Entire Database

To display the entire database use Query:

MariaDB [(none)]> show databases;
| Databases |
| database |
| my news |
30 rows in set (0.40 sec)

Creating Database

The basic structure in creating a database with DDL is CREATE database_database_name; then ENTER

CREATE DATABASE learn_database;

Using Database

When finished creating a database, of course the db cannot be used because it has not been entered into the db, then the following command is needed:

Viewing all tables in an active database

To see all tables in an active database, use a query like the one below:

Creating Tables

In creating a table, the query structure that must be made is: CREATE TABLE table_name(name_attribut1 type (10),_name_attribut2 type (20); then ENTER

CREATE TABLE subjects(kode_matkul VARCHAR (10) NOT NULL PRIMARY KEY, nama_matkul VARCHAR (20));

For numbers (10) means that the character length that can be filled in is 10 characters, for NOT NULL means attribute code_matkul cannot be empty, while PRIMARY KEY means attribute code_matkul is the key attribute of the table.

View Table Structure

The structure of the data table is seen by using the command or query as below:
And it will look like below:

+————-+————+——+—-+—- -+——-+
| Fields | Type | Null | Key | Defaults | Extra |
+————-+————+——+—-+—- -+——-+
| code_matkul | varchar(10) | NO | PRI | NULL | |
| name_matkul | varchar(20) | YES | | NULL | |
+————-+————+——+—-+—- -+——-+
2 rows in set (0.05 sec)

In making a table, of course, we must have errors or mistakes and need improvements to the table structure, for example, adding attributes or columns, increasing character lengths or column lengths, deleting attributes and others, so we use queries. ALTER to do all the commands or change as in the example above with the query structure is ALTER TABLE table_name [spesifikasi_perubahan]. The purpose of the specification_change is the choice in the form of CHANGE, DROPor ADD.

Adding New Attributes

In adding a new attribute or column, the parameters that must be used are ADD as exemplified in the query below:

ALTER TABLE subject_course ADD number varchar (10);

Then it will look like below:

+————-+————+——+—-+—- -+——-+
| Fields | Type | Null | Key | Defaults | Extra |
+————-+————+——+—-+—- -+——-+
| code_matkul | varchar(10) | NO | PRI | NULL | |
| name_matkul | varchar(20) | YES | | NULL | |
| number | varchar(10) | YES | | NULL | |
+————-+————+——+—-+—- -+——-+
3 rows in set (0.06 sec)

Changing Column Names

In changing the name of an attribute or column, the parameters used are CHANGE as exemplified by the following query:

ALTER TABLE CHANGE course number table_number VARCHAR (10);

Removing Attributes

In deleting an attribute in a table, the parameters used are DROP as exemplified by the following query:

ALTER TABLE subject_course DROP table_number;

Definition of DML

DML or Data Manipulating Language are SQL commands that deal with data manipulation in tables. DML itself has a function to perform the following commands:
  1. INSERT to fill data
  2. SELECT to view data
  3. UPDATE to change data
  4. DELETE to delete data

Filling Table

To fill in the data on the attribute by using a query as below:

INSERT INTO subjects (kode_matkul, nama_matkul) VALUES (‘1’, ‘Database’);

Viewing the entire table

To see all the contents of a table that has been filled in, use a query like the one below:

SELECT * FROM subject_course;

Then the screen will display as below:

| code_matkul | name_matkul |
| 1 | Database |
| 2 | Statistics |
| 3 | Software Engineering |
| 4 | Machine Learning |
4 rows in set (0.00 sec)

View Table Specific Contents

There are times when we will display the contents of a more specific table, for example, only displaying record code ‘1’ or showing record name_matkul who has character ‘Y’then the query looks like this:

SELECT * FROM courses WHERE Kode_matkul=”1″;

Then it will appear like this:

| code_matkul | name_matkul |
| 1 | Database |
1 row in set (0.03 sec)

Or want to display data in a table subject which only has character ‘Y’ just, the example is like the query below:

SELECT * FROM subjects WHERE nama_matkul LIKE ‘%y%’;

In section LIKE ‘%y%’ means the system will display the character ‘y’ which is among other characters, can also use ‘y%’ for the first character in the word, or ‘%y’ to display data that has character y at the end of the word

Limiting the Number of Attributes That Will Be Displayed

Not all of the attributes in the table must be displayed, sometimes only a few attributes will be displayed, so the query used is as follows:

SELECT nama_matkul FROM subject_course;

So that attributes that are not called will not appear, as below:

| name_matkul |
| Database |
| Statistics |
| Software Engineering |
| Machine Learning |
4 rows in set (0.00 sec)

Displaying Data Sequentially

Sometimes the data displayed is not sequential, with random numbers it will be very confusing if the data is very large, then there is a little additional function so that the data can be sequentially from the largest to the smallest or vice versa, as in the example below:

SELECT * FROM courses ORDER BY Kode_matkul ASC;

In the above query is a command to display data sequentially from the smallest to the largest value, now below is the opposite, from largest to smallest. The only difference is the function ASC (Ascending) and DESC (Descending)

SELECT * FROM courses ORDER BY Kode_matkul DESC;

Changing Table Contents

To change the contents of the data table, the query used is as in the example below:

UPDATE SET nama_matkul=”Indonesian” WHERE Kode_matkul=”7″;

To change one field then it must have a reference attribute with clause WHERE attribute primary keyif not then fill field everything will change

Deleting Data

To delete data in a table, the query used is as in the example below:

DELETE courses WHERE Kode_matkul=”7″;

Just like update, delete must also use clause WHERE with the goal is the primary key as a reference deletion.
That’s all about DDL and DML, I hope you understand, if you don’t understand, please write in the comments what you don’t understand. See you papa

thank you for downloading MySQL : DDL and DML In SQL – Rull
, hopefully it can be useful for all of you. search for your other digital needs by using the search menu in the header of this site.