Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
6d5afc20
Commit
6d5afc20
authored
Aug 10, 2010
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
<example> is a floating element, so it's use is inappropriate when the
surrounding text refers to the example inline.
parent
20bf5e03
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
20 deletions
+7
-20
doc/src/sgml/datatype.sgml
doc/src/sgml/datatype.sgml
+7
-20
No files found.
doc/src/sgml/datatype.sgml
View file @
6d5afc20
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.25
5 2010/07/29 19:34:40
petere Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.25
6 2010/08/10 20:41:27
petere Exp $ -->
<chapter id="datatype">
<chapter id="datatype">
<title>Data Types</title>
<title>Data Types</title>
...
@@ -2877,10 +2877,6 @@ CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
...
@@ -2877,10 +2877,6 @@ CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
Once created, the enum type can be used in table and function
Once created, the enum type can be used in table and function
definitions much like any other type:
definitions much like any other type:
</para>
<example>
<title>Basic Enum Usage</title>
<programlisting>
<programlisting>
CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
CREATE TABLE person (
CREATE TABLE person (
...
@@ -2894,7 +2890,7 @@ SELECT * FROM person WHERE current_mood = 'happy';
...
@@ -2894,7 +2890,7 @@ SELECT * FROM person WHERE current_mood = 'happy';
Moe | happy
Moe | happy
(1 row)
(1 row)
</programlisting>
</programlisting>
</example
>
</para
>
</sect2>
</sect2>
<sect2>
<sect2>
...
@@ -2905,10 +2901,7 @@ SELECT * FROM person WHERE current_mood = 'happy';
...
@@ -2905,10 +2901,7 @@ SELECT * FROM person WHERE current_mood = 'happy';
order in which the values were listed when the type was created.
order in which the values were listed when the type was created.
All standard comparison operators and related
All standard comparison operators and related
aggregate functions are supported for enums. For example:
aggregate functions are supported for enums. For example:
</para>
<example>
<title>Enum Ordering</title>
<programlisting>
<programlisting>
INSERT INTO person VALUES ('Larry', 'sad');
INSERT INTO person VALUES ('Larry', 'sad');
INSERT INTO person VALUES ('Curly', 'ok');
INSERT INTO person VALUES ('Curly', 'ok');
...
@@ -2934,7 +2927,7 @@ WHERE current_mood = (SELECT MIN(current_mood) FROM person);
...
@@ -2934,7 +2927,7 @@ WHERE current_mood = (SELECT MIN(current_mood) FROM person);
Larry
Larry
(1 row)
(1 row)
</programlisting>
</programlisting>
</example
>
</para
>
</sect2>
</sect2>
<sect2>
<sect2>
...
@@ -2942,11 +2935,8 @@ WHERE current_mood = (SELECT MIN(current_mood) FROM person);
...
@@ -2942,11 +2935,8 @@ WHERE current_mood = (SELECT MIN(current_mood) FROM person);
<para>
<para>
Each enumerated data type is separate and cannot
Each enumerated data type is separate and cannot
be compared with other enumerated types.
be compared with other enumerated types. See this example:
</para>
<example>
<title>Lack of Casting</title>
<programlisting>
<programlisting>
CREATE TYPE happiness AS ENUM ('happy', 'very happy', 'ecstatic');
CREATE TYPE happiness AS ENUM ('happy', 'very happy', 'ecstatic');
CREATE TABLE holidays (
CREATE TABLE holidays (
...
@@ -2962,15 +2952,12 @@ SELECT person.name, holidays.num_weeks FROM person, holidays
...
@@ -2962,15 +2952,12 @@ SELECT person.name, holidays.num_weeks FROM person, holidays
WHERE person.current_mood = holidays.happiness;
WHERE person.current_mood = holidays.happiness;
ERROR: operator does not exist: mood = happiness
ERROR: operator does not exist: mood = happiness
</programlisting>
</programlisting>
</
example
>
</
para
>
<para>
<para>
If you really need to do something like that, you can either
If you really need to do something like that, you can either
write a custom operator or add explicit casts to your query:
write a custom operator or add explicit casts to your query:
</para>
<example>
<title>Comparing Different Enums by Casting to Text</title>
<programlisting>
<programlisting>
SELECT person.name, holidays.num_weeks FROM person, holidays
SELECT person.name, holidays.num_weeks FROM person, holidays
WHERE person.current_mood::text = holidays.happiness::text;
WHERE person.current_mood::text = holidays.happiness::text;
...
@@ -2980,7 +2967,7 @@ SELECT person.name, holidays.num_weeks FROM person, holidays
...
@@ -2980,7 +2967,7 @@ SELECT person.name, holidays.num_weeks FROM person, holidays
(1 row)
(1 row)
</programlisting>
</programlisting>
</
example
>
</
para
>
</sect2>
</sect2>
<sect2>
<sect2>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment