Prev | Current Page 1142 | Next

Michael McCallister

"openSUSE Linux Unleashed"

With the new database created, and a
user account with access to the database, you are ready to start playing with data!
Creating Tables
Once you are in the PostgreSQL database, it is just a matter of using standard SQL
commands to create tables and insert data:
test=> create table employees (
test(> empid int4 primary key not null,
test(> lastname varchar,
test(> firstname varchar,
test(> salary float4);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index ???employees_pkey??? for
table ???employees???
CREATE TABLE
test=>
This command creates the new employees table. To verify that it has been created, use the
\dt meta-command:
test=> \dt
List of relations
Schema | Name _| Type | Owner
??”??”??”??”+??”??”??”??”??”-+??”??”??”-+??”??”??”??”??”
public | employees | table | rich
(1 row)
test=> select * from employees;
empid | lastname | firstname | salary
??”??”??”-+??”??”??”??”??”+??”??”??”??”??”-+??”??”??”??”
(0 rows)
test=>
The table exists and has no data. Now you can put data into the table using the INSERT
command:
test=> insert into employees values (1, ???Blum??™, ???Rich??™, 25000);
INSERT 0 1
test=> insert into employees values (2, ???Blum??™, ???Barbara??™, 55000);
INSERT 0 1
test=> select * from employees;
empid | lastname | firstname | salary
??”??”??”-+??”??”??”??”??”+??”??”??”??”??”-+??”??”??”??”
1 | Blum | Rich | 25000
CHAPTER 29 Managing Databases 604
2 | Blum | Barbara | 55000
(2 rows)
test=>
The data was successfully added to the table.


Pages:
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154
katalog stron żetony do pokera śmieszne dowcipy bajka Connie Talbot