The range type would allow best performance and simple queries.
If you have some string values like k
and Pre-K
mixed with numeric values, just create a grade table with a rank value (an integer value representing actual sort order):
CREATE TABLE grade(
grade text PRIMARY KEY
,grade_int UNIQUE int NOT NULL
);
Your numeric grades can conveniently be assigned the same grade_value
, other grades get integer values according to their rank.
You might write a simple function to convert ranges with your original string values to their integer representations on the fly ...
And vice-versa to display your grades_served
column where needed.
Convert grades_served
to an int4range
type.
Using the overlap operator &&
, your query for a range of grades can then simply be:
SELECT * FROM tbl WHERE grades_served && '[1,4]'::int4range;
Or, for a single grade, the "contains element" operator @>
SELECT * FROM tbl WHERE grades_served @> -1;
Index
If your table is not very small I suggest you create a GiST index to support that (and so does the manual).
CREATE INDEX tbl_grades_served_idx ON tbl USING gist (grades_served);
So I received help on this issue from a colleague who is an experienced programmer.
In order to add a password to the page:
sudo nano /etc/apache2/conf-enabled/phppgadmin.conf
Then, modify the .conf file to include the following text within the block (I placed it underneath the 'allow from all' line that I uncommented previously):
AuthUserFile /usr/share/phppgadmin/.htpasswd
AuthName "Restricted Area"
AuthType Basic
require valid-user
Save this file and exit.
Change directory to phppgadmin:
cd /usr/share/phppgadmin
Create password file (change 'your username' and get rid of triangle brackets):
sudo htpasswd -c .htpasswd <your username>
Enter password twice when prompted.
Restart the apache service and the page will now be password protected.
In order to add a superuser to access phppgadmin(again, (change 'your username' and get rid of triangle brackets):
sudo su - postgres
createuser -P -s <your username>
Again, enter password twice when prompted. This will now allow you to login to to phppgadmin.
Erwin's answer is also helpful too, it just seems as if he takes a different approach to solving the issue. Although I did not use Erwin's method, it should accomplish the same thing. However, I did not need to adjust listen_address
in postgresql.conf
in order to make it work.
Best Answer
I don't use phpPgAmin.
To change an existing column definition to use the
CYCLE
attribute you need to understand that this is an attribute of the sequence not the "column".A
serial
orbigserial
is only a shorthand notation to assign a default value to a column which is take from a sequence.When you define a column as
serial
Postgres automatically creates a sequences and applies the necessary default expression.The sequence is usually called
<table_name>_<column_name>_seq
. But you can run a query to get the name of the generated sequence:Once you know the name of the sequence, you can do the following:
(Note that you need to
commit
that if you are not using auto-commit mode).Here are some relevant links to the manual:
ALTER SEQUENCE
: http://www.postgresql.org/docs/current/static/sql-altersequence.html