Home > Software engineering >  What do you call the <database>.<table> syntax in SQL?
What do you call the <database>.<table> syntax in SQL?

Time:07-20

In many databases, when writing a SELECT query, you can provide the database name along with the table name in order to resolve any ambiguity the database might encounter in case there are multiple databases with the same table names.

For example, let's say the user currently logged into SQL Server has SELECT privileges on databases DB1 and DB2, and BOTH databases have a table named CUSTOMERS. The following query would return an error stating that the table name is too ambiguous:

SELECT * FROM CUSTOMERS

The solution is to be more specific so the database knows which table to query from:

SELCT * FROM DB1.CUSTOMERS

My question is, what is the name for the <database>.<table> syntax in SQL? I'm asking so that my terminology is correct when explaining it to junior devs.

CodePudding user response:

These are typically called "qualified" and names, and they can be used when an "unqualified" name is ambiguous, for example when a select query pulls data from multiple tables that share column names.

  • Related