Discover primary / unique keys in Sybase ASE

我只是一个虾纸丫 提交于 2019-12-02 04:14:06

When you explicitly declare a key field - say in a CREATE TABLE statement - this doesn't populate the syskeys table. You would use (e.g.) sp_primarykeys to do that. This allows you to 'register' in the syskeys tables the primary, foreign keys, etc. that you would like to be discoverable by an application. You can declare a primary key in this way, even if there is no actual constraint enforced on the field in question.

The stored procedure sp_helpconstraint can be used to find all the keys (etc.) that are defined for a table.

To query for all tables in a database you'd need to use the sysindexes table and look at, e.g. the status field.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!