Posted by
ads' corner
on
Friday, 2011-04-01 Posted in [Postgresql-News][Pwn]
In today’s fast development cycles and with the available, rapidly changing technologies there is less time for the rational planning of a new application. Since the database is usually the last in the development chain, programmers tend to avoid learning yet another programming language for relational databases. The PostgreSQL Project is aware of this problem.
To enable this feature, the new GUC natural_language must be changed from off to english:
1
2
3
4
test=#SET natural_language TO'english';
SET
test=#SET client_min_messages TO'notice';
SET
From now on queries can be formulated in the English language. If users find the concept handy, other languages are also possible. A error-free English or American spelling is currently a mandatory requirement.
Queries must no longer be formally written in SQL, the ending semicolon can be optionally replaced with a dot.
1
2
3
4
5
6
7
8
9
10
11
12
test=# return allrowsfromtable customer.
NOTICE: Translated natural query into: SELECT*FROM"customer";
test=# I need the first three lines fromtable customer, only columns id andname.
NOTICE: Translated natural query into: SELECT id, nameFROM"customer"LIMIT3;
test=# Please retrn allfromtable purchases, sorted bydate.
ERROR: syntax error ator near "all"ROW1: Please retrn allfrom...^
test=# Please return allfromtable purchases, sorted bydate.
NOTICE: Translated natural query into: SELECT*FROM"purchases"ORDERBYdate;
test=#Fetchallrowsfromtable purchases with today's date in the date column, ordered by primary key.
NOTICE: Translated natural query into: SELECT * FROM "purchases" WHERE "date" = NOW()::DATE ORDER BY "id";
test=# Return "name" from the customer table where the value starts with an 'a'.
NOTICE: Translated natural query into: SELECT "name" FROM "customer" WHERE "name" ~ '^a';
Tables can be described with words:
1
2
3
4
test=# Need a tablefor user_data, which has a surrogate key, a timestamp, and a username andpasswordcolumn, bothtext.
NOTICE: Choosing "id"for surrogate keycolumn.
NOTICE: Choosing "inserted_at"fortimestampcolumn.
NOTICE: Translated natural query into: CREATETABLE"user_data" ("id"SERIALPRIMARYKEY, "inserted_at"TIMESTAMPWITH TIME ZONENOTNULLDEFAULT NOW(), "username"TEXT, "password"TEXT);
More complex tables should be created in the traditional way, to not confuse the language parser.
The language parser is currently somewhat restricted in it’s functionality, but will be expanded in future versions.
Since PostgreSQL is an open source product, patches are always welcome.
We strongly expect that this new feature will help the less experienced developers to achieve faster results.