Page 1 of 1
Can we run a select * query for a production DB2 table?
Posted: Mon Feb 13, 2023 9:32 am
by Abhishek Mehta
Hi,
Can we run a select * query for a production DB2 table??
Please let me know.
Re: Can we run a select * query for a production DB2 table?
Posted: Thu Feb 16, 2023 5:25 pm
by Anuj Dhawan
You "can' use it, however it's not recommend in static SQL. SELECT * is recommended mostly for use with dynamic SQL and view definitions.
You can use SELECT * in static SQL, but doing so is not recommended because of first, possible host variable compatibility and performance implications. Suppose that you add a column to the table to which SELECT * refers. If you have not defined a receiving host variable for that column, an error might occur, or the data from the added column might not be retrieved.
If you list the column names in a static SELECT statement instead of using an asterisk, you can avoid problems that might occur with SELECT *. You can also see the relationship between the receiving host variables and the columns in the result table.
Re: Can we run a select * query for a production DB2 table?
Posted: Mon Feb 27, 2023 5:39 pm
by Abhishek Mehta
Thanks Anuj.
This make it very clear, thanks for the great explanation.
Re: Can we run a select * query for a production DB2 table?
Posted: Wed Mar 01, 2023 10:49 am
by Anuj Dhawan
Glad that I had been helpful.
Good luck,
Re: Can we run a select * query for a production DB2 table?
Posted: Wed Mar 08, 2023 1:19 pm
by Abhishek Mehta
Thanks Anuj!