Question about the enum type
От | Tim Hart |
---|---|
Тема | Question about the enum type |
Дата | |
Msg-id | 793e4076f59c9210064cce23464e3ea2@mac.com обсуждение исходный текст |
Ответы |
Re: Question about the enum type
Re: Question about the enum type |
Список | pgsql-general |
I was playing around with the enum type today. I was toying around with a schema to model information about baseball, and decided to create an enum named position: tjhart=# create type position as enum('pitcher', 'catcher', 'first base', 'second base', 'third base', 'short stop', 'left field', 'center field', 'right field', 'designated hitter', 'pinch hitter'); CREATE TYPE At first, I thought I had done something wrong: tjhart=# select 'pitcher'::position; ERROR: syntax error at or near "position" LINE 1: select 'pitcher'::position; It took a bit of fumbling and reading - and closer inspection of the following before I determined what happened: tjhart=# \dT+ public.*; List of data types Schema | Name | Internal name | Size | Description --------+------------+---------------+------+------------- public | "position" | position | 4 | (1 row) tjhart=# select 'right field'::"position"; position ------------- right field (1 row) tjhart=# The example 'mood' enum in the documentation isn't quoted when it's created. I noticed that 'position' is a function, but I can create types with the same name as other functions (abs), and the name isn't quoted. I also tried creating an enum type with a reserved word: tjhart=# create type select as enum('foo'); ERROR: syntax error at or near "select" LINE 1: create type select as enum('foo'); ^ I'm just toying around, so this isn't high priority. I'll probably change the name of the enum to fielding_position for clarity's sake anyway. But for my own education - what's so unique about the name 'position'? Tim Hart
В списке pgsql-general по дате отправления: