Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

SQL Domain Constraints: constraints applied to a data type providing centralized management and data validity

1
vote
0answers
43 views

Is it possible to define a cast between text and a domain representing a uuid to avoid manual casts?

I created a DOMAIN as following: CREATE DOMAIN country_id AS uuid; I create such domains for readability. It is much easier to read function definitions which accept a country_id instead of a uuid. ...
1
vote
0answers
73 views

In PostgreSQL, how to deal with error messages that show almost no context?

Today I realized a number of points where PostgreSQL (v10.3) is rather lackluster and sparse in its error messages. The first point is illustrated by this code: drop schema if exists X cascade; ...
2
votes
1answer
83 views

Ranges over domains do not trigger implicit casting

As far as I was able to find out, it is currently not possible in PostgreSQL v9.5 (and above?) to obtain implicit casting with custom range types. To illustrate, when I define the following demo setup:...
7
votes
2answers
439 views

Does SQL Server support custom DOMAINs?

PostgreSQL supports the DOMAIN specification, from SQL 2011 working draft spec, A domain is a named user-defined object that can be specified as an alternative to a data type in certain places ...
2
votes
1answer
86 views

What are the drawbacks of using DOMAINS to store metadata about the column?

I came across a question about a data type for MD5 values. The recommendation in that question states using uuid as type for that field. The argumentation is solid. But I find that this might be ...
3
votes
3answers
3k views

Creating a DOMAIN in MySQL or MariaDB?

As far as I know, DOMAINS cannot be created in MySQL. Is there any disadvantage for that? Is there something to be used instead of using CREATE DOMAIN?
2
votes
2answers
1k views

How do I list the constraints of a DOMAIN?

Consider the following scenario: CREATE DOMAIN dom_zipcode AS text; ALTER DOMAIN dom_zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5); Now, if I want to drop that constraint with ALTER ...
2
votes
1answer
55 views

Can I create a DOMAIN on a range of years

I have to create a custom domain that is an interval between two years, but i actually need both years. For example: '2013/2014' '2015/2016' Is there a way to pack both years inside a single domain, ...
3
votes
1answer
2k views

Show DOMAIN details

Showing the columns and constrains of a table in PostgreSQL is done with: \d+ <table_name> Which lists the columns, data types and modifiers for a table. How can I show the details and ...
2
votes
1answer
365 views

How to apply a newly-created Domain to an existing Column?

In Postgres 9.4 Beta 1, I successfully created a domain of type VARCHAR, fuel_domain_. The domain checks that a value is any of 5 possible strings, coal, gas, wind, hydro, other. CREATE DOMAIN ...
0
votes
1answer
64 views

Use a DOMAIN in multiple schemas

The PostgreSQL CREATE DOMAIN command appears to create the domain at the schema level. Is there a best approach I should be aware of that would allow me to reuse domains across the multiple schemas ...
1
vote
2answers
49 views

Making a domain conditional on other values in the table

How can I define or change a domain based on another attribute value? F.e. domain for salary is a numeric value > 500. But if a date the person was hired > January 1st, 2013, then the salary must be >...