Chapter 2. SQL Syntax9The following are Postgres reserved words which are also SQL92 or SQL3 reserved words,and which are allowed to be present as column labels, but not as identifiers:CASE COALESCE CROSS CURRENTELSE ENDFALSE FOREIGNGLOBAL GROUPLOCALNULLIFORDERPOSITION PRECISIONTABLE THEN TRANSACTION TRUEWHEN

The following are Postgres reserved words which are also SQL92 or SQL3 reserved words:ADD ALL ALTER AND ANY AS ASCBEGIN BETWEEN BOTH BYCASCADE CAST CHAR CHARACTER CHECK CLOSECOLLATE COLUMN COMMIT CONSTRAINTCREATE CURRENT_DATE CURRENT_TIMECURRENT_TIMESTAMP CURRENT_USER CURSORDECIMAL DECLARE DEFAULT DELETE DESC DISTINCT DROPEXECUTE EXISTS EXTRACTFETCH FLOAT FOR FROM FULLGRANTHAVINGIN INNER INSERT INTERVAL INTO ISJOINLEADING LEFT LIKE LOCALNAMES NATIONAL NATURAL NCHAR NO NOT NULL NUMERICON OR OUTERPARTIAL PRIMARY PRIVILEGES PROCEDURE PUBLICREFERENCES REVOKE RIGHT ROLLBACKSELECT SET SUBSTRINGTO TRAILING TRIMUNION UNIQUE UPDATE USER USINGVALUES VARCHAR VARYING VIEWWHERE WITH WORK

The following are SQL92 reserved key words which are not Postgres reserved key words, butwhich if used as function names are always translated into the function length:CHAR_LENGTH CHARACTER_LENGTH

The following are SQL92 or SQL3 reserved key words which are not Postgres reserved keywords, but if used as type names are always translated into an alternate, native type:BOOLEAN DOUBLE FLOAT INT INTEGER INTERVAL REAL SMALLINT

Chapter 2. SQL Syntax10The following are either SQL92 or SQL3 reserved key words which are not key words inPostgres. These have no proscribed usage in Postgres at the time of writing (v6.5) but maybecome reserved key words in the future:Note: Some of these key words represent functions in SQL92. These functions are definedin Postgres, but the parser does not consider the names to be key words and they areallowed in other contexts.

ExpressionsSQL92 allows expressions to transform data in expressions. Expressions may contain operators(see Operators for more details) and functions (Functions has more information).12Chapter 3. Data TypesDescribes the built-in data types available in Postgres.Postgres has a rich set of native data types available to users. Users may add new types toPostgres using the DEFINE TYPE command described elsewhere.In the context of data types, the following sections will discuss SQL standards compliance,porting issues, and usage. Some Postgres types correspond directly to SQL92-compatible types.In other cases, data types defined by SQL92 syntax are mapped directly into native Postgrestypes. Many of the built-in types have obvious external formats. However, several types areeither unique to Postgres, such as open and closed paths, or have several possibilities forformats, such as the date and time types.

Chapter 3. Data Types14Note: The cidr and inet types are designed to handle any IP type but only ipv4 is handledin the current implementation. Everything here that talks about ipv4 will apply to ipv6 in afuture release.

Table 3-2. Postgres Function ConstantsPostgres FunctionSQL92 ConstantDescriptiongetpgusername()current_useruser name in current sessiondate(’now’)current_datedate of current transactiontime(’now’)current_timetime of current transactiontimestamp(’now’)current_timestampdate and time of current transaction

Postgres has features at the forefront of ORDBMS development. In addition to SQL3conformance, substantial portions of SQL92 are also supported. Although we strive for SQL92compliance, there are some aspects of the standard which are ill considered and which shouldnot live through subsequent standards. Postgres will not make great efforts to conform to thesefeatures; however, these tend to apply in little-used or obsure cases, and a typical user is notlikely to run into them.Most of the input and output functions corresponding to the base types (e.g., integers andfloating point numbers) do some error-checking. Some of the operators and functions (e.g.,addition and multiplication) do not perform run-time error-checking in the interests ofimproving execution speed. On some systems, for example, the numeric operators for somedata types may silently underflow or overflow.Note that some of the input and output functions are not invertible. That is, the result of anoutput function may lose precision when compared to the original input.Note: The original Postgres v4.2 code received from Berkeley rounded all double precisionfloating point results to six digits for output. Starting with v6.1, floating point numbers areallowed to retain most of the intrinsic precision of the type (typically 15 digits for doubles, 6digits for 4-byte floats). Other types with underlying floating point fields (e.g. geometrictypes) carry similar precision.

Chapter 3. Data Types15Numeric TypesNumeric types consist of two- and four-byte integers and four- and eight-byte floating pointnumbers.Table 3-3. Postgres Numeric TypesNumeric TypeStorageDescriptionRangefloat44 bytesVariable-precision6 decimal placesfloat88 bytesVariable-precision15 decimal placesint22 bytesFixed-precision-32768 to +32767int44 bytesUsual choice forfixed-precision-2147483648 to +2147483647int88 bytesVery large rangefixed-precision+/- > 18 decimal placesserial4 bytesIdentifer or cross-reference0 to +2147483647The numeric types have a full set of corresponding arithmetic operators and functions. Refer toNumerical Operators and Mathematical Functions for more information.The serial type is a special-case type constructed by Postgres from other existing components.It is typically used to create unique identifiers for table entries. In the current implementation,specifyingCREATE TABLE tablename (colname SERIAL);is equivalent to specifying:CREATE SEQUENCE tablename_colname_seq;CREATE TABLE tablename(colname INT4 DEFAULT nextval(’tablename_colname_seq’);CREATE UNIQUE INDEX tablename_colname_key on tablename (colname);CautionThe implicit sequence created for the serial type will not be automatically removedwhen the table is dropped. So, the following commands executed in order will likelyfail:CREATE TABLE tablename (colname SERIAL);DROP TABLE tablename;CREATE TABLE tablename (colname SERIAL);The sequence will remain in the database until explicitly dropped using DROPSEQUENCE.Chapter 3. Data Types16

The int8 type may not be available on all platforms since it relies on compiler support for this.Monetary TypeThe money type supports US-style currency with fixed decimal point representation. IfPostgres is compiled with USE_LOCALE then the money type should use the monetaryconventions defined for locale(7).Table 3-4. Postgres Monetary TypesMonetary TypeStorageDescriptionRangemoney4 bytesFixed-precision-21474836.48 to +21474836.47numeric will replace the money type, and should be preferred.Character TypesSQL92 defines two primary character types: char and varchar. Postgres supports these types, inaddition to the more general text type, which unlike varchar does not require an upper limit tobe declared on the size of the field.Table 3-5. Postgres Character TypesCharacter TypeStorageRecommendationDescriptionchar1 byteSQL92-compatibleSingle characterchar(n)(4+n) bytesSQL92-compatibleFixed-length blank paddedtext(4+x) bytesBest choiceVariable-lengthvarchar(n)(4+n) bytesSQL92-compatibleVariable-length with limitThere is one other fixed-length character type. The name type only has one purpose and that isto provide Postgres with a special type to use for internal names. It is not intended for use bythe general user. It’s length is currently defined as 32 chars but should be reference usingNAMEDATALEN. This is set at compile time and may change in a future release.Table 3-6. Postgres Specialty Character TypeCharacter TypeStorageDescriptionname32 bytesThirty-two character internal typeChapter 3. Data Types17Date/Time TypesThere are two fundamental kinds of date and time measurements provided by Postgres:absolute clock times and relative time intervals. Both kinds of time measurements shoulddemonstrate both continuity and smoothness.Postgres supplies two primary user-oriented date and time types, datetime and timespan, aswell as the related SQL92 types timestamp, interval, date and time.In a future release, datetime and timespan are likely to merge with the SQL92 typestimestamp, interval. Other date and time types are also available, mostly for historical reasons.

SQL92 ConventionsPostgres endeavors to be compatible with SQL92 definitions for typical usage. However, theSQL92 standard has an odd mix of date and time types and capabilities. Two obvious problemsare:Although the date type does not have an associated time zone, the time type can or does.The default time zone is specified as a constant integer offset from GMT/UTC.Time zones in the real world can have no meaning unless associated with a date as well as atime since the offset may vary through the year with daylight savings time boundaries.To address these difficulties, Postgres associates time zones only with date and time typeswhich contain both date and time, and assumes local time for any type containing only date ortime. Further, time zone support is derived from the underlying operating system time zonecapabilities, and hence can handle daylight savings time and other expected behavior.In future releases, the number of date/time types will decrease, with the currentimplementation of datetime becoming timestamp, timespan becoming interval, and (possibly)abstime and reltime being deprecated in favor of timestamp and interval. The more arcanefeatures of the date/time definitions from the SQL92 standard are not likely to be pursued.Chapter 3. Data Types19Date/Time StylesOutput formats can be set to one of four styles: ISO-8601, SQL (Ingres), traditional Postgres,and German.Table 3-9. Postgres Date StylesStyle SpecificationDescriptionExampleISOISO-8601 standard1997-12-17 07:37:16-08SQLTraditional style12/17/1997 07:37:16.00 PSTPostgresOriginal styleWed Dec 17 07:37:16 1997 PSTGermanRegional style17.12.1997 07:37:16.00 PSTThe SQL style has European and non-European (US) variants, which determines whethermonth follows day or vica versa.Table 3-10. Postgres Date Order ConventionsStyle SpecificationDescriptionExampleEuropeanRegional convention17/12/1997 15:37:16.00 METNonEuropeanRegional convention12/17/1997 07:37:16.00 PSTUSRegional convention12/17/1997 07:37:16.00 PSTThere are several ways to affect the appearance of date/time types:The PGDATESTYLE environment variable used by the backend directly on postmasterstartup.The PGDATESTYLE environment variable used by the frontend libpq on session startup.SET DATESTYLE SQL command.For Postgres v6.4 (and earlier) the default date/time style is "non-European traditionalPostgres". In future releases, the default may become "ISO" (compatible with ISO-8601),which alleviates date specification ambiguities and Y2K collation problems.CalendarPostgres uses Julian dates for all date/time calculations. They have the nice property ofcorrectly predicting/calculating any date more recent than 4713BC to far into the future, usingthe assumption that the length of the year is 365.2425 days.Date conventions before the 19th century make for interesting reading, but are not consistantenough to warrant coding into a date/time handler.Chapter 3. Data Types20Time ZonesPostgres obtains time zone support from the underlying operating system for dates between1902 and 2038 (near the typical date limits for Unix-style systems). Outside of this range, alldates are assumed to be specified and used in Universal Coordinated Time (UTC).All dates and times are stored internally in Universal UTC, alternately known as GreenwichMean Time (GMT). Times are converted to local time on the database server before being sentto the client frontend, hence by default are in the server time zone.There are several ways to affect the time zone behavior:The TZ environment variable used by the backend directly on postmaster startup as thedefault time zone.The PGTZ environment variable set at the client used by libpq to send time zoneinformation to the backend upon connection.The SQL command SET TIME ZONE sets the time zone for the session.If an invalid time zone is specified, the time zone becomes GMT (on most systems anyway).Date/Time InputGeneral-use date and time is input using a wide range of styles, including ISO-compatible,SQL-compatible, traditional Postgres and other permutations of date and time. In cases whereinterpretation can be ambiguous (quite possible with many traditional styles of datespecification) Postgres uses a style setting to resolve the ambiguity.Most date and time types share code for data input. For those types the input can have any of awide variety of styles. For numeric date representations, European and US conventions candiffer, and the proper interpretation is obtained by using the SET DATESTYLE commandbefore entering data. Note that the style setting does not preclude use of various styles forinput; it is used primarily to determine the output style and to resolve ambiguities.The special values current, infinity and -infinity are provided. infinity specifies a time laterthan any other valid time, and -infinity specifies a time earlier than any other valid time. currentindicates that the current time should be substituted whenever this value appears in acomputation.The strings now, today, yesterday, tomorrow, and epoch can be used to specify time values.now means the current transaction time, and differs from current in that the current time isimmediately substituted for it. epoch means Jan 1 00:00:00 1970 GMT.

Table 3-12. Postgres Date InputExampleDescriptionJanuary 8, 1999Unambiguous text month1999-01-08ISO-86011/8/1999US; read as August 1 in European mode8/1/1999European; read as August 1 in US mode1/18/1999US; read as January 18 in any mode1999.008Year and day of year19990108ISO-8601 year, month, day990108ISO-8601 year, month, day1999.008Year and day of year99008Year and day of yearJanuary 8, 99 BCYear 99 before the Christian Era

Chapter 3. Data Types23Table 3-15. Postgres Time InputExampleDescription04:05:06.789ISO-8601, with all time fields04:05:06ISO-860104:05ISO-8601040506ISO-860104:05 AMSame as 04:05; AM does not affect value04:05 PMSame as 16:05; input hour must be <= 12zSame as 00:00:00zuluSame as 00:00:00allballsSame as 00:00:00

See Date/Time Support for details on time zones recognized by Postgres.Note: If the compiler option USE_AUSTRALIAN_RULES is set then EST refers to AustraliaEastern Std Time, which has an offset of +10:00 hours from UTC.

Australian time zones and their naming variants account for fully one quarter of all time zonesin the Postgres time zone lookup table.datetimeGeneral-use date and time is input using a wide range of styles, including ISO-compatible,SQL-compatible, traditional Postgres (see section on "absolute time") and other permutationsChapter 3. Data Types24of date and time. Output styles can be ISO-compatible, SQL-compatible, or traditionalPostgres, with the default set to be compatible with Postgres v6.0.datetime is specified using the following syntax:Year-Month-Day [ Hour : Minute : Second ] [AD,BC] [ Timezone ]YearMonthDay [ Hour : Minute : Second ] [AD,BC] [ Timezone ]Month Day [ Hour : Minute : Second ] Year [AD,BC] [ Timezone ]whereYear is 4013 BC, ..., very largeMonth is Jan, Feb, ..., Dec or 1, 2, ..., 12Day is 1, 2, ..., 31Hour is 00, 02, ..., 23Minute is 00, 01, ..., 59Second is 00, 01, ..., 59 (60 for leap second)Timezone is 3 characters or ISO offset to GMT

Valid dates are from Nov 13 00:00:00 4013 BC GMT to far into the future. Timezones areeither three characters (e.g. "GMT" or "PST") or ISO-compatible offsets to GMT (e.g. "-08" or"-08:00" when in Pacific Standard Time). Dates are stored internally in Greenwich Mean Time.Input and output routines translate time to the local time zone of the server.timespanGeneral-use time span is input using a wide range of syntaxes, including ISO-compatible,SQL-compatible, traditional Postgres (see section on "relative time") and other permutations oftime span. Output formats can be ISO-compatible, SQL-compatible, or traditional Postgres,with the default set to be Postgres-compatible. Months and years are a "qualitative" timeinterval, and are stored separately from the other "quantitative" time intervals such as day orhour. For date arithmetic, the qualitative time units are instantiated in the context of therelevant date or time.Time span is specified with the following syntax:Quantity Unit [Quantity Unit...] [Direction]@ Quantity Unit [Direction]whereQuantity is ..., -1, 0, 1, 2, ...Unit is second, minute, hour, day, week, month, year,decade, century, millenium, or abbreviations or plurals of theseunits.Direction is ago.abstimeAbsolute time (abstime) is a limited-range (+/- 68 years) and limited-precision (1 sec) datedata type. datetime may be preferred, since it covers a larger range with greater precision.Absolute time is specified using the following syntax:Month Day [ Hour : Minute : Second ] Year [ Timezone ]whereMonth is Jan, Feb, ..., DecDay is 1, 2, ..., 31Hour is 01, 02, ..., 24Minute is 00, 01, ..., 59Second is 00, 01, ..., 59Year is 1901, 1902, ..., 2038Chapter 3. Data Types25Valid dates are from Dec 13 20:45:53 1901 GMT to Jan 19 03:14:04 2038 GMT.Historical Note: As of Version 3.0, times are no longer read and written using GreenwichMean Time; the input and output routines default to the local time zone.All special values allowed for datetime are also allowed for "absolute time".reltimeRelative time reltime is a limited-range (+/- 68 years) and limited-precision (1 sec) time spandata type. timespan should be preferred, since it covers a larger range with greater precisionand, more importantly, can distinguish between relative units (months and years) andquantitative units (days, hours, etc). Instead, reltime must force months to be exactly 30 days,so time arithmetic does not always work as expected. For example, adding one reltime year toabstime today does not produce today’s date one year from now, but rather a date 360 daysfrom today.reltime shares input and output routines with the other time span types. The section ontimespan covers this in more detail.timestampThis is currently a limited-range absolute time which closely resembles the abstime data type.It shares the general input parser with the other date/time types. In future releases this type willabsorb the capabilities of the datetime type and will move toward SQL92 compliance.timestamp is specified using the same syntax as for datetime.intervalinterval is an SQL92 data type which is currently mapped to the timespan Postgres data type.tintervalTime ranges are specified as:[ ’abstime’ ’abstime’]whereabstime is a time in the absolute time format.Special abstime values such as current’, infinity’ and -infinity’ can be used.Chapter 3. Data Types26Boolean TypePostgres supports bool as the SQL3 boolean type. bool can have one of only two states: ’true’or ’false’. A third state, ’unknown’, is not implemented and is not suggested in SQL3; NULL isan effective substitute. bool can be used in any boolean expression, and boolean expressionsalways evaluate to a result compatible with this type.bool uses 1 byte of storage.Table 3-17. Postgres Boolean TypeStateOutputInputTrue’t’TRUE, ’t’, ’true’, ’y’, ’yes’, ’1’False’f’FALSE, ’f’, ’false’, ’n’, ’no’, ’0’Geometric TypesGeometric types represent two-dimensional spatial objects. The most fundamental type, thepoint, forms the basis for all of the other types.Table 3-18. Postgres Geometric TypesGeometric TypeStorageRepresentationDescriptionpoint16 bytes(x,y)Point in spaceline32 bytes((x1,y1),(x2,y2))Infinite linelseg32 bytes((x1,y1),(x2,y2))Finite line segmentbox32 bytes((x1,y1),(x2,y2))Rectangular boxpath4+32n bytes((x1,y1),...)Closed path (similar to polygon)path4+32n bytes[(x1,y1),...]Open pathpolygon4+32n bytes((x1,y1),...)Polygon (similar to closed path)circle24 bytes<(x,y),r>Circle (center and radius)A rich set of functions and operators is available to perform various geometric operations suchas scaling, translation, rotation, and determining intersections.Chapter 3. Data Types27PointPoints are the fundamental two-dimensional building block for geometric types.point is specified using the following syntax:( x , y )x , ywherex is the x-axis coordinate as a floating point numbery is the y-axis coordinate as a floating point numberLine SegmentLine segments (lseg) are represented by pairs of points.lseg is specified using the following syntax:( ( x1 , y1 ) , ( x2 , y2 ) )( x1 , y1 ) , ( x2 , y2 )x1 , y1 , x2 , y2where(x1,y1) and (x2,y2) are the endpoints of the segmentBoxBoxes are represented by pairs of points which are opposite corners of the box.box is specified using the following syntax:( ( x1 , y1 ) , ( x2 , y2 ) )( x1 , y1 ) , ( x2 , y2 )x1 , y1 , x2 , y2where(x1,y1) and (x2,y2) are opposite cornersBoxes are output using the first syntax. The corners are reordered on input to store the lowerleft corner first and the upper right corner last. Other corners of the box can be entered, but thelower left and upper right corners are determined from the input and stored.PathPaths are represented by connected sets of points. Paths can be "open", where the first and lastpoints in the set are not connected, and "closed", where the first and last point are connected.Functions popen(p) and pclose(p) are supplied to force a path to be open or closed, andfunctions isopen(p) and isclosed(p) are supplied to select either type in a query.path is specified using the following syntax:( ( x1 , y1 ) , ... , ( xn , yn ) )[ ( x1 , y1 ) , ... , ( xn , yn ) ]( x1 , y1 ) , ... , ( xn , yn )( x1 , y1 , ... , xn , yn )x1 , y1 , ... , xn , ynwhere(x1,y1),...,(xn,yn) are points 1 through na leading "[" indicates an open patha leading "(" indicates a closed pathChapter 3. Data Types28Paths are output using the first syntax. Note that Postgres versions prior to v6.1 used a formatfor paths which had a single leading parenthesis, a "closed" flag, an integer count of the numberof points, then the list of points followed by a closing parenthesis. The built-in functionupgradepath is supplied to convert paths dumped and reloaded from pre-v6.1 databases.PolygonPolygons are represented by sets of points. Polygons should probably be considered equivalentto closed paths, but are stored differently and have their own set of support routines.polygon is specified using the following syntax:( ( x1 , y1 ) , ... , ( xn , yn ) )( x1 , y1 ) , ... , ( xn , yn )( x1 , y1 , ... , xn , yn )x1 , y1 , ... , xn , ynwhere(x1,y1),...,(xn,yn) are points 1 through nPolygons are output using the first syntax. Note that Postgres versions prior to v6.1 used aformat for polygons which had a single leading parenthesis, the list of x-axis coordinates, thelist of y-axis coordinates, followed by a closing parenthesis. The built-in function upgradepolyis supplied to convert polygons dumped and reloaded from pre-v6.1 databases.CircleCircles are represented by a center point and a radius.circle is specified using the following syntax:< ( x , y ) , r >( ( x , y ) , r )( x , y ) , rx , y , rwhere(x,y) is the center of the circler is the radius of the circleCircles are output using the first syntax.IP Version 4 Networks and Host AddressesThe cidr type stores networks specified in CIDR (Classless Inter-Domain Routing) notation.The inet type stores hosts and networks in CIDR notation using a simple variation inrepresentation to represent simple host TCP/IP addresses.Table 3-19. Postgres IP Version 4 TypesIPV4 TypeStorageDescriptionRangecidrvariableCIDR networksValid IPV4 CIDR blocksinetvariablenets and hostsValid IPV4 CIDR blocksChapter 3. Data Types29CIDRThe cidr type holds a CIDR network. The format for specifying classless networks is x.x.x.x/ywhere x.x.x.x is the network and /y is the number of bits in the netmask. If /y omitted, it iscalculated using assumptions from the older classfull naming system except that it is extendedto include at least all of the octets in the input.Here are some examples:Table 3-20. Postgres CIDR ExamplesCIDR InputCIDR Displayed192.168.1192.168.1/24192.168192.168.0/24128.1128.1/16128128.0/16128.1.2128.1.2/2410.1.210.1.2/2410.110.1/161010/8

inetThe inet type is designed to hold, in one field, all of the information about a host including theCIDR-style subnet that it is in. Note that if you want to store proper CIDR networks, youshould use the cidr type. The inet type is similar to the cidr type except that the bits in the hostpart can be non-zero. Functions exist to extract the various elements of the field.The input format for this function is x.x.x.x/y where x.x.x.x is an internet host and y is thenumber of bits in the netmask. If the /y part is left off, it is treated as /32. On output, the /y partis not printed if it is /32. This allows the type to be used as a straight host type by just leavingoff the bits part.30Chapter 4. OperatorsDescribes the built-in operators available in Postgres.Postgres provides a large number of built-in operators on system types. These operators aredeclared in the system catalog pg_operator. Every entry in pg_operator includes the name ofthe procedure that implements the operator and the class OIDs of the input and output types.To view all variations of the || string concatenation operator, trySELECT oprleft, oprright, oprresult, oprcodeFROM pg_operator WHERE oprname = ’||’;oprleft|oprright|oprresult|oprcode-------+--------+---------+-------25| 25| 25|textcat1042| 1042| 1042|textcat1043| 1043| 1043|textcat(3 rows)

Users may invoke operators using the operator name, as in:select * from emp where salary < 40000;

Alternatively, users may call the functions that implement the operators directly. In this case,the query above would be expressed as:select * from emp where int4lt(salary, 40000);

psql has a command (\dd) to show these operators.Lexical PrecedenceOperators have a precedence which is currently hardcoded into the parser. Most operators havethe same precedence and are left-associative. This may lead to non-intuitive behavior; forexample the boolean operators "<" and ">" have a different precedence that the booleanoperators "<=" and ">=".Chapter 4. Operators31Table 4-1. Operator Ordering (decreasing precedence)ElementPrecedenceDescriptionUNIONleftSQL select construct::Postgres typecasting[ ]leftarray delimiters.lefttable/column delimiter-rightunary minus;leftstatement termination, logarithm:rightexponentiation|leftstart of interval* / %leftmultiplication, division+ -leftaddition, subtractionIStest for TRUE, FALSE, NULLISNULLtest for NULLNOTNULLtest for NOT NULL(all other operators)native and user-definedINset membershipBETWEENcontainmentLIKEstring pattern matching< >boolean inequality=rightequalityNOTrightnegationANDleftlogical intersectionORleftlogical unionChapter 4. Operators32General OperatorsThe operators listed here are defined for a number of native data types, ranging from numerictypes to data/time types.

Chapter 4. Operators35Time Interval OperatorsThe time interval data type tinterval is a legacy from the original date/time types and is not aswell supported as the more modern types. There are several operators for this type.Table 4-5. Postgres Time Interval OperatorsOperatorDescriptionUsage#<Interval less than?#<=Interval less than or equal to?#<>Interval not equal?#=Interval equal?#>Interval greater than?#>=Interval greater than or equal to?<#>Convert to time interval<<Interval less than?|Start of interval~=Same as<?>Time inside interval?