PL/SQL Declare loop if

Source: Internet
Author: User

--1. Determine if the table exists, or drop table if present--2. Create a table--3. Inserting 1W data--4. Commit once per 1K articleDeclarev_tablevarchar2(222):='STUDENT';--Table nameV_table_exists Number:=0;--if it is greater than 0, the table existsV_sql_createvarchar2(2222);--CREATE TABLE SQLV_number Number:=500000;--the inserted datav_id Number:=0;--ID fieldV_age Number:=100000;--Age FieldV_i Number:=0;--record the number of inserted barsV_start_timevarchar2( A);--Execute command start timeV_end_timevarchar2( A);--Execute command End timeV_exec_timevarchar( A);begin    --determine if the table exists, if there is the most deleted    SelectTo_char (Sysdate,'YYYY-MM-DD Hh24:mi:ss') intoV_start_time fromdual; Select Count(1) intoV_table_exists fromtabwhereTname=Upper('Student'); ifV_table_exists> 0     Then        ExecuteImmediate'drop table'||V_table||'Purge'; Dbms_output.put_line ('drop table'||V_table||'sucessfuly'); ElseDbms_output.put_line ('Table'||V_table|| 'is not exists'); End if; --CREATE TABLE StudentV_sql_create:='CREATE TABLE'||V_table||'(ID number,age number)'; Executeimmediate v_sql_create; Commit; --Insert data to studentLoopExit  whenV_number<=0; V_number:=V_number-1; Insert  intoStudentValues(V_id,v_age); V_ID:=v_id+1; V_age:=V_age+1; V_i:=V_i+1; --commit/10000 Line Data        ifMoD (V_i,10000)=0         Then            SelectTo_char (Sysdate,'YYYY-MM-DD Hh24:mi:ss') intoV_exec_time fromdual; Dbms_output.put_line (V_i||' '||v_exec_time); Commit; End if; EndLoop; SelectTo_char (Sysdate,'YYYY-MM-DD Hh24:mi:ss') intoV_end_time fromdual; Dbms_output.put_line ('Execute sucess'||V_start_time||' -'||v_end_time);End;/

PL/SQL Declare loop if

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.