Memcached in your servant VPS
29 August, 2017
5 plugins of backup for WordPress
12 September, 2017

Tricks SQL €“ To eliminate duplicated registries

The technology advances to exaggerated steps, so that the great majority of companies must face every day massive volumes of data, which are stored in data bases. This way, they can be modified and be analyzed in the future of a simple way. An ample fan of relational database management systems in the market as for example Oracle or MySQL exists.

What is SQL? Which are their characteristics?

Sql (Structured Query Language) is a programming language that is used to obtain data from a data base with the purpose of to recover it and/or to update it. At the moment, SQL is the standard language of international communication within the data bases since it allows the access and data manipulation in the same.

Language SQL is made up of sentences. Each of these sentences is an instruction that the user sends to the data base and are formed by two words. On the one hand, those own ones of language SQL; and, on the other hand, the words related to the data stored in the data base at issue.

It is necessary to consider that this programming language nondifference between capital letters and small letters.

What operations allow to make language SQL in a data base?

Since we have indicated, this programming language allows to accede and to realise consultations in data bases of a fast and simple way. This way, any user, thanks to SQL can create new data bases, as well as create new tables in these registry and data bases, new in the tables. Also he can erase table, data bases and registry. And, by all means, search data and to realise the modifications that he considers opportune.

How to eliminate duplicated registries of a data base with SQL?

At corporative level, the data bases in the great majority of cases usually are very extensive. Thus, it turns out complicated to imagine for example in a data base with 200,000 registries that usuary determining must look for and eliminate those duplicated registries of way manual. Language SQL allows to do it of a form very simple and, in addition, totally trustworthy.

First it is to decide the criterion of duplicity based on the data stored in the base.

Next, it constructs the following commando, soliciing to the data base that analyzes columns 1 and 2 of the Tabla1.

SELECT col1, col2, COUNT (*) FROM Tabla1

GROUP BY col1, col2

HAVING COUNT (*) > 1

It selects that the duplicated values are stored in a maintenance table.

SELECT col1, col2, COUNT (*)

INTO holdkey

FROM Tabla1

GROUP BY col1, col2

HAVING COUNT (*) > 1

This way, you are indicating to the data base that is only stored an only registry. Thus, if you have a same twice stored registry, it will eliminate one of them; whereas if you have stored it four times, it will eliminate three of them so that it is one.

To eliminate registries duplicated with SQL improvement of remarkable way the optimization of the data base.

It lets a commentary

Your email address will not be published. The obligatory fields are noticeable with *

This site uses Akismet to reduce the Spam. It learns how the data of your commentaries are processed.