Home > Database > Mysql Tutorial > postgressql批量增加数据

postgressql批量增加数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 14:58:50
Original
1538 people have browsed it

postgressql批量增加数据 批量增加数据脚本add_batch.sql Java代码 create function add_account(INTEGER) returns TEXT as DECLARE num INTEGER := 1; input_num ALIAS FOR $1; number INTEGER := 0; BEGIN number :=num+input_num; WHILE num number loop

postgressql批量增加数据

 

批量增加数据脚本add_batch.sql 

 

Java代码  

create function add_account(INTEGER) returns TEXT as '  

DECLARE  

num INTEGER := 1;   

input_num ALIAS FOR $1;  

number INTEGER := 0;    

BEGIN   

    number :=num+input_num;  

    WHILE num

        insert into tbl_real_net (real_id,net_id)  

         values( num,num +1);  

        num :=num +1;  

    end loop;  

    RETURN ''增加成功'';  

END;'   

language 'plpgsql';  

 

批量增加记录说明 

 

1.把add_batch.sql文件拷贝到/database/pg/postgresql-7.3.1/bin目录下 

2.执行以下命令 

 

Java代码  

1.------su pg  

2.------cd /database/pg/postgresql-7.3.1/bin  

3.------./createlang plpgsql beap  

4.------./psql mytest

5.------./psql mytest  

6.------select add_account(10000);  

 

注意: 

执行到4时,如果成功会返回字符串CREATE FUNCTION。 

执行到6时,如果成功会显示’增加成功‘。 

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template