What is the meaning of the principal_id
in sys.schemas
and when would it ever be different from schema_id
?
1> SELECT LEFT(name,20), schema_id, principal_id FROM sys.schemas;
2> GO
schema_id principal_id
-------------------- ----------- ------------
dbo 1 1
guest 2 2
INFORMATION_SCHEMA 3 3
sys 4 4
db_owner 16384 16384
db_accessadmin 16385 16385
db_securityadmin 16386 16386
db_ddladmin 16387 16387
db_backupoperator 16389 16389
db_datareader 16390 16390
db_datawriter 16391 16391
db_denydatareader 16392 16392
db_denydatawriter 16393 16393
(13 rows affected)
Internally, I see that the schema_id
comes from sys.sysclsobjs
while the principal_id
comes from sys.syssingleobjrefs
's r.indepid
field.