Download - Introductions to Postgresql

Transcript

1. PostgreSQL 2. ) with( ... ) ... ( ORDBMS CREATETABLEcities(nametext,populationreal,altitudeint); CREATETABLEcapitals(statechar(2))INHERITS(cities); 3. CREATEORREPLACEFUNCTIONget_cities() RETURNScitiesAS 'select*fromcities;' ALTERFUNCTIONget_cities()OWNERTOpostgres; selectrow_to_json(get_cities()); Createtypestateas(state_codeint,state_namevarchar(10)); CREATETABLEcapitals1(statestate)INHERITS(cities); insertintocapitals1values('mashhad',300,1,(1,'KH')); 4. With statement WITHRECURSIVEt(n)AS( VALUES(1) UNIONALL SELECTn+1FROMtWHEREn