2

Can someone explain the difference in semantics between the following:

select count(*) from dbo.SomeTable;
select count(*) from SomeTable;
select count(*) from ..SomeTable;
select count(*) from somedb..SomeTable;
select count(*) from somedb.dbo.SomeTable;

They all seem to yield the same results in my system.

More specifically I have this theory that somedb..SomeTable actually means:

the object SomeTable owned by the user I am currently connected as in the database somedb.

Is this correct?

If so, given then that usernames appear to serve to partition table names into different namespaces, can't it be said that Sybase conflates the concept of a user to that of a schema? (since schemas are what other RDBMSs use to namespace tables?)

Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
  • 2
    format is `[database.][owner.]table`; if periods are included, but `owner` is blank then the system will first look for a table owned by your db user (`user_name()`), then it will look for a table owned by the database owner (`dbo`); if 2 periods are included but `database` is left blank then the system will look for the object in the database where your session currently resides (`db_name()`); for stored procs (and functions) that start with `sp_`, if database is not supplied then the system will look for the proc/function in current db, then `sybsystemprocs` db, then `master` db – markp-fuso Oct 25 '17 at 22:53
  • clarification on the format ... if only one period is provided then it's parsed as `owner.table`; to provide `database` there must be 2 periods – markp-fuso Oct 25 '17 at 23:32
  • format " database.owner.table " if you are providing empty striing between .. it means compiler will lookout if the current db connection user and database are such that, the table reside in same db, user is dbo . if you explicitly provide values and execute sql then irrespective of db to which you are connected and user you are you should be able to select data from table ( provided your user has permission to select data) – Nishad Feb 05 '18 at 11:34

0 Answers0