Out of interest when working with SQL statements should I always use the fully qualifed column name (tablename.columnname) even if only working with one table e.g.
SELECT table.column1, table.column2 FROM table
A fully qualified procedure name is a three-part name. The first part is a location name that identifies the DBMS at which the procedure is stored. The second part is the schema name of the stored procedure. The third part is an SQL identifier.
A qualifier for a column name can be a table name, a view name, an alias name, a synonym, or a correlation name. Whether a column name can be qualified depends, like its meaning, on its context. In some forms of the COMMENT and LABEL statements, a column name must be qualified.
Aliases can be useful when: There are more than one table involved in a query. Functions are used in the query. Column names are big or not very readable.
Column names must contain only A to Z, 0 to 9, and underscore (_) characters. Column names can contain multiple underscores. The column name must not be very generic. Avoid words such as term, multiplier, description, name, code, and so on.
It's better if you do - it doesn't add any complexity, and it can prevent errors in the future.
But in a well-defined system, you shouldn't have to - it's like namespaces in programming languages. The ideal is not to have conflicts, but it can clutter the code with the superfluous use of explicit names.
-Adam
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With