免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: stone531
打印 上一主题 下一主题

postgreSQL 有什么办法让外键的约束效果暂时失效 [复制链接]

论坛徽章:
7
数据库技术版块每日发帖之星
日期:2015-08-08 06:20:00数据库技术版块每日发帖之星
日期:2015-08-29 06:20:00数据库技术版块每日发帖之星
日期:2015-08-29 06:20:00数据库技术版块每日发帖之星
日期:2015-09-18 06:20:00数据库技术版块每周发帖之星
日期:2015-11-06 19:56:51数据库技术版块每日发帖之星
日期:2016-01-22 06:20:00数据库技术版块每日发帖之星
日期:2016-02-05 06:20:00
11 [报告]
发表于 2014-02-17 14:36 |只看该作者
如果有多个外键,你要搞清楚到底要查哪个外键
我举的例子就是有两个外键
  1. create table t(a int primary key, b int, c int, d int);
  2. create table t1(a int primary key, b int, c int, d int);
  3. create table s(a1 int references t(a), a2 int references t1(a), a3 int);

  4. postgres=# select conname from pg_constraint where contype = 'f' and conrelid = (select oid from pg_class where relname = 's');
  5.   conname  
  6. -----------
  7. s_a1_fkey
  8. s_a2_fkey
  9. (2 rows)

  10. postgres=# \d s
  11.        Table "public.s"
  12. Column |  Type   | Modifiers
  13. --------+---------+-----------
  14. a1     | integer |
  15. a2     | integer |
  16. a3     | integer |
  17. Foreign-key constraints:
  18.     "s_a1_fkey" FOREIGN KEY (a1) REFERENCES t(a)
  19.     "s_a2_fkey" FOREIGN KEY (a2) REFERENCES t1(a)

复制代码
回复 10# stone531


   

论坛徽章:
0
12 [报告]
发表于 2014-02-17 23:29 |只看该作者
谢谢
回复 11# asdf2110


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP