SELECT COLUMN SQL

Why do we need to use a query SELECT COLUMN1, COLUMN2when we can just use SELECT *and show only the columns we need?

And what is the difference between SELECT ALLand SELECT?

+4
source share
3 answers

The question is, why use SELECT col1, col2it when you can just show which columns you like in the application and always use it SELECT *?

The main reasons are as follows:

  • Selecting only the columns you want means that the server needs to collect and send less data to the application, making it faster to request and less using resources, especially if you have many columns or some of them contain BLOBs.
  • (, , , select, .
  • , , , . , - .

:

, SELECT ALL SELECT , .
SELECT ALL - SELECT , .

SELECT DISTINCT . , , :

SELECT DISTINCT col1, col2 

,

1,2
1,2
2,2
2,3

1,2
2,2
2,3
+3

SELECT Col1, Col2 vs SELECT *

,

.

/? SELECT * SELECT column1, colum2, column3 ..

Select * Select

* vs select column


SELECT ALL SELECT: , SELECT Col1, Col2 SELECT ALL Col1, Col2

SELECT:

SELECT [ALL | DISTINCT] column1[,column2] FROM table1

ALL .

+2

, , "SELECT COLUMN" , "SELECT ALL".

0

Source: https://habr.com/ru/post/1570794/


All Articles