Oracle generates a serial number function

Source: Internet
Author: User

1: Valid time range for smalldatetime on date range 1900/1/1~2079/6/6valid time range for datetime 1753/1/1~9999/ A/ to2: The accuracy of the smalldatetime is only accurate to the point, while the DateTime can be accurate to 3-bit milliseconds. 3: smalldatetime occupies 4 bytes on storage space, and the first 2 bytes store the number of days after base date (January 1, 1900). The second 2 bytes stores the number of minutes after midnight. DateTime occupies 8 bytes, the first 4 bytes store the number of days before or after base date (that is, January 1, 1900), and the last 4 bytes store the number of milliseconds after midnight Oracle generates a serial number functionCREATE OR REPLACE FUNCTIONFn_no_make (V_typeVARCHAR2, V_number_colVARCHAR2, V_table_nameVARCHAR2)/** Parameter Description: * v_type: Encoding prefix * V_NUMBER_COL: The column name of the code * V_table_name: The name of the table in which the code is located*/ RETURN VARCHAR2  isV_old_noVARCHAR2( -);--Original CodeV_old_num Number;--five digit number after the original codeV_new_numVARCHAR2(Ten);--new coded five digit numberV_maked_noVARCHAR2( -);--new CodeV_date_noVARCHAR2( -);--Current date numberV_sqlVARCHAR2(4000);BEGINV_sql:= 'SELECT MAX (' ||V_number_col|| ') from' ||V_table_name; EXECUTEIMMEDIATE V_sql intoV_old_no; V_sql:= 'SELECT SUBSTR (To_char (Sysdate,"'YYMMDD"'), 1, 6) as Date_no from DUAL'; EXECUTEIMMEDIATE V_sql intoV_date_no; V_old_num:=To_number (substr (V_old_no, One,5)); V_new_num:=To_char (V_old_num+ 1);  whileLength (V_new_num)< 5LOOP V_new_num:= '0' ||V_new_num; ENDLOOP; IFV_old_no is NULL ORsubstr (V_old_no,5,6)<>V_date_no ThenV_maked_no:=V_type||V_date_no|| '00001'; ELSEV_maked_no:=V_type||V_date_no||V_new_num; END IF; RETURN(V_MAKED_NO); EXCEPTION whenOTHERS ThenDbms_output.put_line (SQLERRM);ENDFn_no_make;1. Database import, Export command Data export: A. Full export of database test, user Name System Password Manager exported to D:\daochu.dmpExpTest/Test@ORACLE_192.168.28.1 file=D:\daochu.dmp Full=YB. Export the system user in the database with the table of the SYS userExpTest/Test@ORACLE_192.168.28.1  file=D:\DAOCHU.DMP owner=(System,sys) data import: A imports the data from the D:\DAOCHU.DMP into the test database. Imp Dev/Dev@ORACLE_192.168.28.2  file=d:\daochu.dmp Imp Dev/Dev@ORACLE_192.168.28.2  Full=Yfile=file=D:\data\newsmgnt.dmp Ignore=y may have a problem, because some tables already exist, and then it's an error, and the table is not imported. Add Ignore to the back .=y can do it. B Import the table table1 from d:\daochu.dmp to imp Dev/Dev@TEST  file=D:\DAOCHU.DMP tables=(table1)2. Clob,blob Import and Export command in database tablesExpDatabase user Name/Password@ Configuration Name  file=Output file pathLog=Log file path tables=(database table name) query=\ "Query condition \" IMP database user name/Password@ Configuration Name  file=Input file pathLog=Log file path tables=(database table name) ignore=yExpTest/Test@ORACLE_192.168.28.1  file=C + One. DMPLog=C + One.LogTables=(table1) Query=\"whereCreatedBy='sysadmin'   andTo_char (Createtime,'YYYY-MM-DD')='2012-05-17'\ "Imp Dev/Dev@ORACLE_192.168.28.2 file=C + One. DMPLog=C +121.LogTables=(table1) Ignore=y do it with Cmd.exe, the place to note is the query place \ "Execute IMP after exp is executed first

Oracle generates a serial number function

Related Article

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.