Recently in the study of PostgreSQL, so also has a strong interest in pl/pgsql, so here is a little summary, first of all, this PL is procedure language shorthand, that is, the so-called "process language." A large part of the following is quoted
1. Return statementThere are three commands that can be used to return data from a function:
RETURN
RETURN NEXT
RETURN QUERY
2. Return command syntax:RETURN RETURN expression;If you do not use the expression return command to
Symfoware Open System"DDL" (data definition Language)A data definition language that defines and manages the language of all objects in a SQL database. The main commands are create, alter, DROP, etc., the DDL is mainly used in the initialization of
Test environment: win2003 + postgresql8.3 (postgresql89.0 is not easy to use)
1. Create a database language
1. Open the Start Menu/Program/PostgreSQL 8.3/command prompt
2. Run the "createlang-u Postgres plpgsql S" command"
For example,
N-more SQL statements, but their own time, but everywhere is the pit ah, ah, ah!!!!!!!!!!!!!!!Want to write a get the latest ID value in the table.On the CodeCREATE TABLEDepartment (IDINT PRIMARY KEY not NULL, D_codeVARCHAR(
There are two tables: user and diff_user_list.
When the user table is added, deleted, modified, and queried, or a field changes, the field is inserted to the diff_user_list table.
The following code stores old records in the diff_user_list table
The time can be added and reduced directly in PostgreSQL: Query System Current Time: Select Now ();OrSelect Current_timestamp; SELECT now ():: Timestamp + ' 1 year '; --Current time plus 1 yearsSELECT now ():: Timestamp + ' 1 month '; --Current
Lang_name Code do executes an anonymous block of code, in other words, an anonymous function that executes once in a program language.A block of code is considered a function body with no parameters, and the return value type is void. Its parsing
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.