其他模式中的约束

时间:2018-05-01 10:12:30

标签: postgresql constraints information-schema

在尝试information_schema.*视图时,我了解到可以在另一个模式中定义约束。这反映在information_schema.table_constraints视图中,该视图添加constaint_schema等列以表示:

select * from information_schema.table_constraints

constraint_catalog | constraint_schema | constraint_name | table_catalog | table_schema | table_name | constraint_type | is_deferrable | initially_deferred 

对于外键,这是有道理的:可以引用另一个模式中的表。

我现在想知道这是否也适用于其他限制。也就是说,是否有可能在另一个模式中定义主要,唯一或检查约束作为定义表的模式? constraint_schema中的table_schemainformation_schema.table_constraints中的NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if(notificationSoundUri != null){ // Changing Default mode of notification notificationCompatBuilder.setDefaults(Notification.DEFAULT_VIBRATE); // Creating an Audio Attribute AudioAttributes audioAttributes = new AudioAttributes.Builder() .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .setUsage(AudioAttributes.USAGE_ALARM) .build(); // Creating Channel NotificationChannel notificationChannel = new NotificationChannel(context.getString(R.string.channel_id_prayers),context.getString(R.string.channel_name_prayers),NotificationManager.IMPORTANCE_HIGH); notificationChannel.setSound(notificationSoundUri,audioAttributes); mNotificationManager.createNotificationChannel(notificationChannel); } } mNotificationManager.notify(0, notificationCompatBuilder.build()); 不同?

1 个答案:

答案 0 :(得分:1)

https://www.postgresql.org/docs/current/static/sql-createindex.html

  

索引始终在与其父表相同的模式中创建

https://www.postgresql.org/docs/current/static/ddl-constraints.html

  

添加唯一约束将自动创建唯一的B树   约束中列出的列或列组的索引。

  

添加主键将自动创建唯一的B树索引   在主键

中列出的列或列组上

因此,pk或unique肯定会与同一模式中的表一起旅行。关于检查而不是空 - 我无法想出任何方式来争论他们为什么不能处于不同的架构中,但要么我都不知道它们如何出现在不同的架构中。