SQL - SPLessons

SQL Clone

Chapter 16

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQL Clone

SQL Clone

shape Description

SQL is a non-procedural language. Client can compose SQL script to execute and SQL compiler consequently produces a method to get to database and convey the fancied output. SQL is a database coding, planned for the recuperation and organisation of data in social database. A record in the SQL Database table is said to be clone. And a SQL Clone can be described as copying the records in the database or replicating the record from the database.

By viewing the below example the concept of Clone can be easily understood.

shape Conceptual figure

  • Agent – Which is used to act as an interface between user and the server.
  • Clone – Copy of record in the database.
  • Database – Is a collection of logical related data.

SQL Clone Example

shape Step - 1

Identify the table records for cloning.

sql> select * from settings where hostname="php";
+-------------+------+----------+
| value       | data | hostname |
+-------------+------+----------+
| AC3PassThru | 0    | php      |
+-------------+------+----------+
1 row in set (0.00 sec)

shape Step - 2

Cloning the above table record “php”.

sql> insert into settings select * from settings where hostname="php";
Query OK, 1 row affected (0.01 sec)
Records: 1  Duplicates: 0  Warnings: 0

sql> select * from settings where hostname="php";
+-------------+------+----------+
| value       | data | hostname |
+-------------+------+----------+
| AC3PassThru | 0    | php      |
| AC3PassThru | 0    | php      |
+-------------+------+----------+
2 rows in set (0.00 sec)

Here in the above example, the host name and all other values are repeated by performing the clone operation.

Summary

shape Key Points

  • SQL Clone – Copying or replicating a record in the database is said to be clone.