SQL Server:INFORMATION_SCHEMA 能否告诉我 SQL 对象何时创建?
鉴于:
- 我向表添加了一个不可为空的外键。
- 我决定采用一种用默认值填充外键的方法。
- 我签入了对可重新运行的数据库创建脚本的两项更改。
- 其他开发人员运行了此脚本,现在他们的外键已在其开发人员计算机上填充了默认值。
然而几天后……
- 我改变了主意。
- 现在我想以不同的方式填充外键的默认值。
我的问题:
可以是 SQL Server 或 INFORMATION_SCHEMA 告诉我 SQL 对象何时创建?
理想情况下,我想删除并重新添加外键如果它是在某个日期/时间之前创建的。
任何帮助或替代策略将不胜感激。
显然,我想避免去每个开发人员的立方体,要求他们手动删除外键。
Given:
- I added a non-nullable foreign key to a table.
- I settled on a way to populate the foreign key with default values.
- I checked in both changes to a re-runnable DB creation script.
- Other developers ran this script, and now they have the foreign key populated with default values on their developer machines.
A few days later however...
- I changed my mind.
- Now I'd like to populate the foreign key's default values differently.
My Question:
Can SQL Server or INFORMATION_SCHEMA
tell me when SQL objects were created?
Ideally, I'd like to drop and re-add the foreign key if it was created before a certain date/time.
Any help or alternative strategies would be greatly appreciated.
Obviously, I'd like to avoid going to each developer's cube, asking them to drop the foreign key manually.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于 SQL 2000
sysobjects
< /a>(对于 SQL 2000),列crdate
对于 SQL 2005+
sys.objects
、create_date
和modify_date
For SQL 2000
sysobjects
(for SQL 2000), columncrdate
For SQL 2005+
sys.objects
,create_date
andmodify_date