I want to get all the data from a table in SQL.The following command can be used:
select * from table_name
But it seems that using * decreases effeciency, so is there any other way ?
I want to get all the data from a table in SQL.The following command can be used:
select * from table_name
But it seems that using * decreases effeciency, so is there any other way ?
You can use following syntax:
SELECT fieldname1,fieldname2,fieldname3 FROM table_name;
You can also optimize it by using limit. Just fetch the number of record you wanted at once.
SELECT fieldname1,fieldname2,fieldname3 FROM table_name LIMIT 10;
You can use
SELECT col_name1, col_name2, col_name3 from Table_Name
This approach is Good compare with SELECT * from Table_Name
The reason to use this approach is at some point, an extra column may be added to that table, and would cause unneeded data to be brought back from the query.
Why Not preferring SELECT * from Table_Name
: Reference : Why not preferring SELECT *