CHAPTER 28 FROM DATABASES TO DATATYPES company=# (Professional web hosting)

CHAPTER 28 FROM DATABASES TO DATATYPES company=# CREATE TABLE contacts (employee_id integer, im im_accounts); CREATE TABLE Next, we insert some data into our table. Note that the syntax for inserting into a composite type simply involves encapsulating the various pieces of information that make up the field within parentheses: company=# INSERT INTO contacts (employee_id, im) company-# VALUES (1,(’bigceo@jabber.org’,'thebigceo’,'bigceo76′)); INSERT 0 1 And finally, for good measure, let s take a look at our data: company=# SELECT * FROM contacts; employee_id | im ————-+—————————————1 | (bigceo@jabber.org,thebigceo,bigceo76) (1 rows) Altering Composite Types The ALTERTYPE command can be used to change the definition of an existing composite type. In versions prior to PostgreSQL 8.1, this is limited to changing the owner of the type: ALTER TYPE im_accounts OWNER TO amber; Starting in 8.1, PostgreSQL also gives you the ability to alter the schema of a given type: ALTER TYPE im_accounts SET SCHEMA mynewschema; Dropping Composite Types Dropping a composite type is done through the DROPTYPE command. By default, you cannot drop a composite type that is referenced by any other objects. This can be controlled by using the CASCADE or RESTRICT keywords, and can be schema-qualified if needed: DROP TYPE mynewschema.im_accounts CASCADE; Note The DROP CASCADE command may have different effects depending on the dependent object. For example, if a table references the composite type, only the column in question will be dropped. However, if a view references the composite type, the entire view will be dropped. Working with Domains Domains can be considered a cross between a datatype and a constraint. Creating a domain generally requires two pieces of information: the underlying base type that the domain will use, and the constraint limiting the acceptable values for the domain. While you might think
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply