PostgreSQL

Скачать в pdf «PostgreSQL»


test=> SELECT * FROM friend ORDER BY age DESC;


firstname


| lastname


| city


| state


| age


Cindy


| Anderson


| Denver


| CO


| 23


Sam


| Jackson


| Allentown


| PA


| 22


Mike


| Nichols


| Tampa


| fl


| 20


(3 rows)

Figure 3.15: Reverse order by


test=> SELECT *


FROM friend WHERE


age >= 21 ORDER BY


firstname;


firstname


| lastname


| city


| state |


age


Cindy


| Anderson


| Denver


| CO |


23


Sam


| Jackson


| Allentown


| pa |


22


(2 rows)

Figure 3.16: Use of order by and where


remove the friend table. Both the table structure and the data contained in the table will be erased. We will use the friend table in the next chapter, so you should not remove the table at this time. Remember—to remove only the data in the table without removing the table structure itself, use delete.

3.10 Summary


This chapter has shown the basic operations of any database:


•    Table creation (create table)


•    Table destruction (drop table)


•    Displaying (select)


•    Adding (insert)


•    Replacing (update)


•    Removing (delete)

Скачать в pdf «PostgreSQL»