Sometimes you need to execute some SQL scripts, with logical control statements, and do not want to use the high-level language C #, Java and the like, you can directly use Plpgsql, similar to Oracle's Plsql.1Do language'Plpgsql' $$2
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
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
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(
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,
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.