• The EDB*Plus command line client provides a user interface to Advanced Server that supports SQL*Plus commands; EDB*Plus allows you to:For detailed installation and usage information about EDB*Plus, please see the EDB*Plus User's Guide, available from the EnterpriseDB website at:
In the following descriptions a term refers to any word or group of words which may be language keywords, user-supplied values, literals, etc. A term’s exact meaning depends upon the context in which it is used.
• Italic font introduces a new term, typically, in the sentence that defines it for the first time.
• Fixed-width (mono-spaced) font is used for terms that must be given literally such as SQL commands, specific table and column names used in the examples, programming language keywords, etc. For example, SELECT * FROM emp;
• Italic fixed-width font is used for terms for which the user must substitute values in actual usage. For example, DELETE FROM table_name;
• Square brackets [ ] denote that one or none of the enclosed term(s) may be substituted. For example, [ a | b ], means choose one of “a” or “b” or neither of the two.
• Braces {} denote that exactly one of the enclosed alternatives must be specified. For example, { a | b }, means exactly one of “a” or “b” must be specified.
• Ellipses ... denote that the proceeding term may be repeated. For example, [ a | b ] ... means that you may have the sequence, “b a a b a”.
Note: The following are important version compatibility restrictions between the EDB*Loader client and the database server.
• Invoking EDB*Loader is done using a client program called edbldr, which is used to pass parameters and directive information to the database server. It is strongly recommended that the 11 EDB*Loader client (that is, the edbldr program supplied with Advanced Server 11) be used to load data only into version 11 of the database server. In general, the EDB*Loader client and database server should be the same version.
One exception is that the Advanced Server rules defined on the table are not enforced. EDB*Loader can load tables on which rules are defined, but the rules are not executed. As a consequence, partitioned tables implemented using rules cannot be loaded using EDB*Loader.Note: Advanced Server rules are created by the CREATE RULE command. Advanced Server rules are not the same database objects as rules and rule sets used in Oracle.
2.2 General UsageGenerally, formatting errors in the data file do not result in an aborted transaction. Instead, the badly formatted records are written to a text file called the bad file. The reason for the error is recorded in the log file.Note: EDB*Loader differs from Oracle SQL*Loader in that a database integrity error results in a rollback in EDB*Loader. In Oracle SQL*Loader, only the record causing the error is rejected. Records that were previously inserted into the table are retained and loading continues after the rejected record.
• [ CHARACTERSET charset ][ INFILE '{ data_file | stdin }' ][ BADFILE 'bad_file' ][ DISCARDFILE 'discard_file' ][ { DISCARDMAX | DISCARDS } max_discard_recs ]{ INTO TABLE target_table[ FIELDS TERMINATED BY 'termstring'[ OPTIONALLY ENCLOSED BY 'enclstring' ] ][ RECORDS DELIMITED BY 'delimstring' ]where field_def defines a field in the specified data_file that describes the location, data format, or value of the data to be inserted into column_name of the target_table. The syntax of field_def is the following:CONSTANT val |[ PRESERVE BLANKS ] [ "expr" ]where fieldtype is one of:The specification of data_file, bad_file, and discard_file may include the full directory path or a relative directory path to the file name. If the file name is specified alone or with a relative directory path, the file is then assumed to exist (in the case of data_file), or is created (in the case of bad_file or discard_file), relative to the current working directory from which edbldr is invoked.
•
• Where ENV_VARIABLE is the environment variable that is set to the directory path and/or file name.The EDBLDR_ENV_STYLE environment variable instructs Advanced Server to interpret environment variable references as Windows-styled references or Linux-styled references irregardless of the operating system on which EDB*Loader resides. You can use this environment variable to create portable control files for EDB*Loader.
• On a Windows system, set EDBLDR_ENV_STYLE to linux or unix to instruct Advanced Server to recognize Linux-style references within the control file.
• On a Linux system, set EDBLDR_ENV_STYLE to windows to instruct Advanced Server to recognize Windows-style references within the control file.The operating system account enterprisedb must have read permission on the directory and file specified by data_file.The operating system account enterprisedb must have write permission on the directories where bad_file and discard_file are to be written.Note: It is suggested that the file names for data_file, bad_file, and discard_file include extensions of .dat, .bad, and .dsc, respectively. If the provided file name does not contain an extension, EDB*Loader assumes the actual file name includes the appropriate aforementioned extension.If an EDB*Loader session results in data format errors and the BADFILE clause is not specified, nor is the BAD parameter given on the command line when edbldr is invoked, a bad file is created with the name control_file_base.bad in the current working directory from which edbldr is invoked. control_file_base is the base name of the control file (that is, the file name without any extension) used in the edbldr session.
• The DISCARDFILE clause for specifying the discard file is not included in the control file.
• The DISCARD parameter for specifying the discard file is not included on the command line.
• The DISCARDMAX clause for specifying the maximum number of discarded records is not included in the control file.
• The DISCARDS clause for specifying the maximum number of discarded records is not included in the control file.
• The DISCARDMAX parameter for specifying the maximum number of discarded records is not included on the command line.If neither the DISCARDFILE clause nor the DISCARD parameter for explicitly specifying the discard file name are specified, but DISCARDMAX or DISCARDS is specified, then the EDB*Loader session creates a discard file using the data file name with an extension of .dsc.Note: There is a distinction between keywords DISCARD and DISCARDS. DISCARD is an EDB*Loader command line parameter used to specify the discard file name (see Section 2.2). DISCARDS is a clause of the LOAD DATA directive that may only appear in the control file. Keywords DISCARDS and DISCARDMAX provide the same functionality of specifying the maximum number of discarded records allowed before terminating the EDB*Loader session. Records loaded into the database before termination of the EDB*Loader session due to exceeding the DISCARDS or DISCARDMAX settings are kept in the database and are not rolled back.If one of INSERT, APPEND, REPLACE, or TRUNCATE is specified, it establishes the default action of how rows are to be added to target tables. If omitted, the default action is as if INSERT had been specified.If the FIELDS TERMINATED BY clause is specified, then the POSITION (start:end) clause may not be specified for any field_def. Alternatively if the FIELDS TERMINATED BY clause is not specified, then every field_def must contain either the POSITION (start:end) clause, the fieldtype(length) clause, or the CONSTANT clause.Use the OPTIONS clause to specify param=value pairs that represent an EDB*Loader directive. If a parameter is specified in both the OPTIONS clause and on the command line when edbldr is invoked, the command line setting is used.If DIRECT is set to TRUE EDB*Loader performs a direct path load instead of a conventional path load. The default value of DIRECT is FALSE.See Section 2.5 for information on direct path loads.ERRORS=error_counterror_count specifies the number of errors permitted before aborting the EDB*Loader session. The default is 50.Set FREEZE to TRUE to indicate that the data should be copied with the rows frozen. A tuple guaranteed to be visible to all current and future transactions is marked as frozen to prevent transaction ID wrap-around. For more information about frozen tuples, see the PostgreSQL core documentation at:You must specify a data-loading type of TRUNCATE in the control file when using the FREEZE option. FREEZE is not supported for direct loading.Set PARALLEL to TRUE to indicate that this EDB*Loader session is one of a number of concurrent EDB*Loader sessions participating in a parallel direct path load. The default value of PARALLEL is FALSE.When PARALLEL is TRUE, the DIRECT parameter must also be set to TRUE . See Section 2.6 for more information about parallel direct path loads.n specifies the number of rows that EDB*Loader will commit before loading the next set of n rows.If EDB*Loader encounters an invalid row during a load (in which the ROWS parameter is specified), those rows committed prior to encountering the error will remain in the destination table.skip_count specifies the number of records at the beginning of the input data file that should be skipped before loading begins. The default is 0.If SKIP_INDEX_MAINTENANCE is TRUE, index maintenance is not performed as part of a direct path load, and indexes on the loaded table are marked as invalid. The default value of SKIP_INDEX_MAINTENANCE is FALSE.You can use the REINDEX command to rebuild an index. For more information about the REINDEX command, see the PostgreSQL core documentation available at:Use the CHARACTERSET clause to identify the character set encoding of data_file where charset is the character set name. This clause is required if the data file encoding differs from the control file encoding. (The control file encoding must always be in the encoding of the client where edbldr is invoked.)File containing the data to be loaded into target_table. Each record in the data file corresponds to a row to be inserted into target_table.If an extension is not provided in the file name, EDB*Loader assumes the file has an extension of .dat, for example, mydatafile.dat.Note: If the DATA parameter is specified on the command line when edbldr is invoked, the file given by the command line DATA parameter is used instead.If the INFILE clause is omitted as well as the command line DATA parameter, then the data file name is assumed to be identical to the control file name, but with an extension of .dat.Specify stdin (all lowercase letters) if you want to use standard input to pipe the data to be loaded directly to EDB*Loader. This is useful for data sources generating a large number of records to be loaded.File that receives data_file records that cannot be loaded due to errors.If an extension is not provided in the file name, EDB*Loader assumes the file has an extension of .bad, for example, mybadfile.bad.Note: If the BAD parameter is specified on the command line when edbldr is invoked, the file given by the command line BAD parameter is used instead.File that receives input data records that are not loaded into any table because none of the selection criteria are met for tables with the WHEN clause, and there are no tables without a WHEN clause. (All records meet the selection criteria of a table without a WHEN clause.)If an extension is not provided in the file name, EDB*Loader assumes the file has an extension of .dsc, for example, mydiscardfile.dsc.Note: If the DISCARD parameter is specified on the command line when edbldr is invoked, the file given by the command line DISCARD parameter is used instead.{ DISCARDMAX | DISCARDS } max_discard_recsMaximum number of discarded records that may be encountered from the input data records before terminating the EDB*Loader session. (A discarded record is described in the preceding description of the discard_file parameter.) Either keyword DISCARDMAX or DISCARDS may be used preceding the integer value specified by max_discard_recs.For example, if max_discard_recs is 0, then the EDB*Loader session is terminated if and when a first discarded record is encountered. If max_discard_recs is 1, then the EDB*Loader session is terminated if and when a second discarded record is encountered.When the EDB*Loader session is terminated due to exceeding max_discard_recs, prior input data records that have been loaded into the database are retained. They are not rolled back.Specifies how data is to be loaded into the target tables. If one of INSERT, APPEND, REPLACE, or TRUNCATE is specified, it establishes the default action for all tables, overriding the default of INSERT.Note: If the table contains rows, the TRUNCATE command must be used to empty the table prior to invoking EDB*Loader. EDB*Loader throws an exception if the DELETE command is used to empty the table instead of the TRUNCATE command. Oracle SQL*Loader allows the table to be emptied by using either the DELETE or TRUNCATE command.The REPLACE keyword and TRUNCATE keywords are functionally identical. The table is truncated by EDB*Loader prior to loading the new data.Note: Delete triggers on the table are not fired as a result of the REPLACE operation.The table is truncated by EDB*Loader prior to loading the new data. Delete triggers on the table are not fired as a result of the truncate operation.Name of the table into which data is to be loaded. The table name may be schema-qualified (for example, enterprisedb.emp). The specified target must not be a view.'val' [ ) ]This conditional clause is used for the WHEN clause, which is part of the INTO TABLE target_table clause, and the NULLIF clause, which is part of the field definition denoted as field_def in the syntax diagram.start and end are positive integers specifying the column positions in data_file that mark the beginning and end of a field that is to be compared with the constant val. The first character in each record begins with a start value of 1.column_name specifies the name assigned to a field definition of the data file as defined by field_def in the syntax diagram.Use of either (start:end) or column_name defines the portion of the record in data_file that is to be compared with the value specified by 'val' to evaluate as either true or false.All characters used in the field_condition text (particularly in the val string) must be valid in the database encoding. (For performing data conversion, EDB*Loader first converts the characters in val string to the database encoding and then to the data file encoding.)In the WHEN field_condition [ AND field_condition ] clause, if all such conditions evaluate to TRUE for a given record, then EDB*Loader attempts to insert that record into target_table. If the insert operation fails, the record is written to bad_file.If for a given record, none of the WHEN clauses evaluate to TRUE for all INTO TABLE clauses, the record is written to discard_file, if a discard file was specified for the EDB*Loader session.See the description of the NULLIF clause in this Parameters list for the effect of field_condition on this clause.String of one or more characters that separates each field in data_file. The characters may be single-byte or multi-byte as long as they are valid in the database encoding. Two consecutive appearances of termstring with no intervening character results in the corresponding column set to null.String of one or more characters used to enclose a field value in data_file. The characters may be single-byte or multi-byte as long as they are valid in the database encoding. Use enclstring on fields where termstring appears as part of the data.String of one or more characters that separates each record in data_file. The characters may be single-byte or multi-byte as long as they are valid in the database encoding. Two consecutive appearances of delimstring with no intervening character results in no corresponding row loaded into the table. The last record (in other words, the end of the data file) must also be terminated by the delimstring characters, otherwise the final record is not loaded into the table.If TRAILING NULLCOLS is specified, then the columns in the column list for which there is no data in data_file for a given record, are set to null when the row is inserted. This applies only to one or more consecutive columns at the end of the column list.If fields are omitted at the end of a record and TRAILING NULLCOLS is not specified, EDB*Loader assumes the record contains formatting errors and writes it to the bad file.Name of a column in target_table into which a field value defined by field_def is to be inserted. If the field definition includes the FILLER or BOUNDFILLER clause, then column_name is not required to be the name of a column in the table. It can be any identifier name since the FILLER and BOUNDFILLER clauses prevent the loading of the field data into a table column.CONSTANT valSpecifies a constant that is type-compatible with the column data type to which it is assigned in a field definition. Single or double quotes may enclose val. If val contains white space, then enclosing quotation marks must be used.The use of the CONSTANT clause completely determines the value to be assigned to a column in each inserted row. No other clause may appear in the same field definition.If the TERMINATED BY clause is used to delimit the fields in data_file, there must be no delimited field in data_file corresponding to any field definition with a CONSTANT clause. In other words, EDB*Loader assumes there is no field in data_file for any field definition with a CONSTANT clause.Specifies that the data in the field defined by the field definition is not to be loaded into the associated column if the identifier of the field definition is an actual column name in the table. In such case, the column is set to null. Use of the FILLER or BOUNDFILLER clause is the only circumstance in which the field definition does not have to be identified by an actual column name.Unlike the BOUNDFILLER clause, an identifier defined with the FILLER clause must not be referenced in a SQL expression. See the discussion of the expr parameter.Specifies that the data in the field defined by the field definition is not to be loaded into the associated column if the identifier of the field definition is an actual column name in the table. In such case, the column is set to null. Use of the FILLER or BOUNDFILLER clause is the only circumstance in which the field definition does not have to be identified by an actual column name.Unlike the FILLER clause, an identifier defined with the BOUNDFILLER clause may be referenced in a SQL expression. See the discussion of the expr parameter.Defines the location of the field in a record in a fixed-width field data file. start and end are positive integers. The first character in the record has a start value of 1.Note: Specification of a field type is optional (for descriptive purposes only) and has no effect on whether or not EDB*Loader successfully inserts the data in the field into the table column. Successful loading depends upon the compatibility of the column data type and the field value. For example, a column with data type NUMBER(7,2) successfully accepts a field containing 2600, but if the field contains a value such as 26XX, the insertion fails and the record is written to bad_file.Please note that ZONED data is not human-readable; ZONED data is stored in an internal format where each digit is encoded in a separate nibble/nybble/4-bit field. In each ZONED value, the last byte contains a single digit (in the high-order 4 bits) and the sign (in the low-order 4 bits).If the POSITION (start:end) clause is specified along with a fieldtype(length) clause, then the ending position of the field is overridden by the specified length value. That is, the length of the value to be loaded into the column is determined by the length value beginning at the start position, and not by the end position of the POSITION (start:end) clause. Thus, the value to be loaded into the column may be shorter than the field defined by POSITION (start:end), or it may go beyond the end position depending upon the specified length size.If the FIELDS TERMINATED BY 'termstring' clause is specified as part of the INTO TABLE clause, and a field definition contains the fieldtype(length) clause, then a record is accepted as long as the specified length values are greater than or equal to the field lengths as determined by the termstring characters enclosing all such fields of the record. If the specified length value is less than a field length as determined by the enclosing termstring characters for any such field, then the record is rejected.If the FIELDS TERMINATED BY 'termstring' clause is not specified, and the POSITION (start:end) clause is not included with a field containing the fieldtype(length) clause, then the starting position of this field begins with the next character following the ending position of the preceding field. The ending position of the preceding field is either the end of its length value if the preceding field contains the fieldtype(length) clause, or by its end parameter if the field contains the POSITION (start:end) clause without the fieldtype(length) clause.If the precision value specified for ZONED conflicts with the length calculated by the server based on information provided with the POSITION clause, EDB*Loader will use the value specified for precision.Note: If the DATE field type is specified along with a SQL expression for the column, then datemask must be specified after DATE and before the SQL expression. See the following discussion of the expr parameter.Note: See the description of field_condition previously listed in this Parameters section for the syntax of field_condition.If all field conditions evaluate to TRUE, then the column identified by column_name in the field definition is set to null. If any field condition evaluates to FALSE, then the column is set to the appropriate value as would normally occur according to the field definition.A SQL expression returning a scalar value that is type-compatible with the column data type to which it is assigned in a field definition. Double quotes must enclose expr. expr may contain a reference to any column in the field list (except for fields with the FILLER clause) by prefixing the column name by a colon character (:).expr may also consist of a SQL SELECT statement. If a SELECT statement is used then the following rules must apply: 1) The SELECT statement must be enclosed within parentheses (SELECT ...). 2) The select list must consist of exactly one expression following the SELECT keyword. 3) The result set must not return more than one row. If no rows are returned, then the returned value of the resulting expression is null. The following is the syntax for use of the SELECT statement:Note: Omitting the FROM table_list clause is not compatible with Oracle databases. If no tables need to be specified, use of the FROM DUAL clause is compatible with Oracle databases.In the preceding control file, the APPEND clause is used to allow the insertion of additional rows into the emp table.The use of the TRAILING NULLCOLS clause allows the last field supplying the comm column to be omitted from the first and last records. The comm column is set to null for the rows inserted from these records.The double quotation mark enclosure character surrounds the value JONES, JR. in the last record since the comma delimiter character is part of the field value.The following example is a control file that loads the same rows into the emp table, but uses a data file containing fixed-width fields:In the preceding control file, the FIELDS TERMINATED BY and OPTIONALLY ENCLOSED BY clauses are absent. Instead, each field now includes the POSITION clause.The following example is a control file that loads the same rows into the emp table, but uses a data file with one physical record. Each individual record that is to be loaded as a row in the table is terminated by the semicolon character (;) specified by the RECORDS DELIMITED BY clause.The following control file illustrates the use of the FILLER clause in the data fields for the sal and comm columns. EDB*Loader ignores the values in these fields and sets the corresponding columns to null.The following control file illustrates the use of the BOUNDFILLER clause in the data fields for the job and mgr columns. EDB*Loader ignores the values in these fields and sets the corresponding columns to null in the same manner as the FILLER clause. However, unlike columns with the FILLER clause, columns with the BOUNDFILLER clause are permitted to be used in an expression as shown for column jobdesc.Note that the POSITION clause and the fieldtype(length) clause can be used individually or in combination as long as each field definition contains at least one of the two clauses.The following example uses the NULLIF clause on the sal column to set it to null for employees of job MANAGER as well as on the comm column to set it to null if the employee is not a SALESMAN and is not in department 30. In other words, a comm value is accepted if the employee is a SALESMAN or is a member of department 30.The comm values from the data file for employees PETERSON, WARREN, ARNOLDS, and MAXWELL are all loaded into the comm column of the emp table since these employees are either SALESMAN or members of department 30.The comm value of 2000.00 in the data file for employee JACKSON is ignored and the comm column of the emp table set to null since this employee is neither a SALESMAN nor is a member of department 30.The following example uses a SELECT statement in the expression of the field definition to return the value to be loaded into the column.Note that the job column contains the value from the dname column of the dept table returned by the SELECT statement instead of the job name from the data file.The following example illustrates the use of multiple INTO TABLE clauses. For this example, two empty tables are created with the same data definition as the emp table. The following CREATE TABLE commands create these two empty tables, while inserting no rows from the original emp table:The following control file contains two INTO TABLE clauses. Also note that there is no APPEND clause so the default operation of INSERT is used, which requires that tables emp_research and emp_sales be empty.The WHEN clauses specify that when the field designated by columns 47 thru 48 contains 20, the record is inserted into the emp_research table and when that same field contains 30, the record is inserted into the emp_sales table. If neither condition is true, the record is written to the discard file named emp_multitbl.dsc.The CONSTANT clause is given for column deptno so the specified constant value is inserted into deptno for each record. When the CONSTANT clause is used, it must be the only clause in the field definition other than the column name to which the constant value is assigned.Finally, column comm of the emp_sales table is assigned a SQL expression. Column names may be referenced in the expression by prefixing the column name with a colon character (:).Since the records for employees ARNOLDS and JACKSON contain 10 and 40 in columns 47 thru 48, which do not satisfy any of the WHEN clauses, EDB*Loader writes these two records to the discard file, emp_multitbl.dsc, whose content is shown by the following:
CONTROL=control_file[ DATA=data_file ][ BAD=bad_file ][ DISCARD=discard_file ][ DISCARDMAX=max_discard_recs ][ LOG=log_file ][ PARFILE=param_file ][ ERRORS=error_count ][ ROWS=n ][ SKIP=skip_count ][ edb_resource_group=group_name ]If the -d option, the -p option, or the -h option are omitted, the defaults for the database, port, and host are determined according to the same rules as other Advanced Server utility programs such as edb-psql, for example.Any parameter listed in the preceding syntax diagram except for the -d option, -p option, -h option, and the PARFILE parameter may be specified in a parameter file. The parameter file is specified on the command line when edbldr is invoked using PARFILE=param_file. Some parameters may be specified in the OPTIONS clause in the control file. See the description of the control file in Section 2.3.The specification of control_file, data_file, bad_file, discard_file, log_file, and param_file may include the full directory path or a relative directory path to the file name. If the file name is specified alone or with a relative directory path, the file is assumed to exist (in the case of control_file, data_file, or param_file), or to be created (in the case of bad_file, discard_file, or log_file) relative to the current working directory from which edbldr is invoked.Note: The control file must exist in the character set encoding of the client where edbldr is invoked. If the client is in a different encoding than the database encoding, then the PGCLIENTENCODING environment variable must be set on the client to the client’s encoding prior to invoking edbldr. This must be done to ensure character set conversion is properly done between the client and the database server.The operating system account used to invoke edbldr must have read permission on the directories and files specified by control_file, data_file, and param_file.The operating system account enterprisedb must have write permission on the directories where bad_file, discard_file, and log_file are to be written.Note: It is suggested that the file names for control_file, data_file, bad_file, discard_file, and log_file include extensions of .ctl, .dat, .bad, .dsc, and .log, respectively. If the provided file name does not contain an extension, EDB*Loader assumes the actual file name includes the appropriate aforementioned extension.EDB*Loader connects to the database with username. username must be a superuser. password is the password for username.If the USERID parameter is omitted, EDB*Loader prompts for username and password. If USERID=username/ is specified, then EDB*Loader 1) uses the password file specified by environment variable PGPASSFILE if PGPASSFILE is set, or 2) uses the .pgpass password file (pgpass.conf on Windows systems) if PGPASSFILE is not set. If USERID=username is specified, then EDB*Loader prompts for password. If USERID=/ is specified, the connection is attempted using the operating system account as the user name.Note: The Advanced Server connection environment variables PGUSER and PGPASSWORD are ignored by EDB*Loader. See the PostgreSQL core documentation for information on the PGPASSFILE environment variable and the password file.CONTROL=control_filecontrol_file specifies the name of the control file containing EDB*Loader directives. If a file extension is not specified, an extension of .ctl is assumed. See Section 2.3 for a description of the control file.DATA=data_filedata_file specifies the name of the file containing the data to be loaded into the target table. If a file extension is not specified, an extension of .dat is assumed. See Section 2.3 for a description of the data_file.Note: Specifying a data_file on the command line overrides the INFILE clause specified in the control file.BAD=bad_filebad_file specifies the name of a file that receives input data records that cannot be loaded due to errors. See Section 2.3 for a description of the bad_file.Note: Specifying a bad_file on the command line overrides any BADFILE clause specified in the control file.DISCARD=discard_filediscard_file is the name of the file that receives input data records that do not meet any table’s selection criteria. See the description of discard_file in Section 2.3.Note: Specifying a discard_file using the command line DISCARD parameter overrides the DISCARDFILE clause in the control file.DISCARDMAX=max_discard_recsmax_discard_recs is the maximum number of discarded records that may be encountered from the input data records before terminating the EDB*Loader session. See the description of max_discard_recs in Section2.3.Note: Specifying max_discard_recs using the command line DISCARDMAX parameter overrides the DISCARDMAX or DISCARDS clause in the control file.LOG=log_filelog_file specifies the name of the file in which EDB*Loader records the results of the EDB*Loader session.If the LOG parameter is omitted, EDB*Loader creates a log file with the name control_file_base.log in the directory from which edbldr is invoked. control_file_base is the base name of the control file used in the EDB*Loader session. The operating system account enterprisedb must have write permission on the directory where the log file is to be written.PARFILE=param_fileparam_file specifies the name of the file that contains command line parameters for the EDB*Loader session. Any command line parameter listed in this section except for the -d, -p, and -h options, and the PARFILE parameter itself, can be specified in param_file instead of on the command line.Any parameter given in param_file overrides the same parameter supplied on the command line before the PARFILE option. Any parameter given on the command line that appears after the PARFILE option overrides the same parameter given in param_file.Note: Unlike other EDB*Loader files, there is no default file name or extension assumed for param_file, though by Oracle SQL*Loader convention, .par is typically used, but not required, as an extension.If DIRECT is set to TRUE EDB*Loader performs a direct path load instead of a conventional path load. The default value of DIRECT is FALSE.See Section 2.5 for information on direct path loads.Set FREEZE to TRUE to indicate that the data should be copied with the rows frozen. A tuple guaranteed to be visible to all current and future transactions is marked as frozen to prevent transaction ID wrap-around. For more information about frozen tuples, see the PostgreSQL core documentation at:You must specify a data-loading type of TRUNCATE in the control file when using the FREEZE option. FREEZE is not supported for direct loading.ERRORS=error_counterror_count specifies the number of errors permitted before aborting the EDB*Loader session. The default is 50.Set PARALLEL to TRUE to indicate that this EDB*Loader session is one of a number of concurrent EDB*Loader sessions participating in a parallel direct path load. The default value of PARALLEL is FALSE.When PARALLEL is TRUE, the DIRECT parameter must also be set to TRUE . See Section 2.6 for more information about parallel direct path loads.n specifies the number of rows that EDB*Loader will commit before loading the next set of n rows.SKIP=skip_countIf set to TRUE, index maintenance is not performed as part of a direct path load, and indexes on the loaded table are marked as invalid. The default value of SKIP_INDEX_MAINTENANCE is FALSE.You can use the REINDEX command to rebuild an index. For more information about the REINDEX command, see the PostgreSQL core documentation available at:edb_resource_group=group_namegroup_name specifies the name of an EDB Resource Manager resource group to which the EDB*Loader session is to be assigned.Any default resource group that may have been assigned to the session (for example, a database user running the EDB*Loader session who had been assigned a default resource group with the ALTER ROLE ... SET edb_resource_group command) is overridden by the resource group given by the edb_resource_group parameter specified on the edbldr command line.In the following example EDB*Loader is invoked using a control file named emp.ctl located in the current working directory to load a table in database edb:In the following example, EDB*Loader prompts for the user name and password since they are omitted from the command line. In addition, the files for the bad file and log file are specified with the BAD and LOG command line parameters.The following example runs EDB*Loader with the same parameters as shown in the preceding example, but using a parameter file located in the current working directory. The SKIP and ERRORS parameters are altered from their defaults in the parameter file as well. The parameter file, emp.par, contains the following:2.4.1 Exit Codes
Indicates that EDB*Loader encountered fatal errors (such as OS errors). This class of errors is equivalent to the FATAL or PANIC severity levels of PostgreSQL errors.
2.5 Direct Path LoadNote: Currently, a direct path load in EDB*Loader is more restrictive than in Oracle SQL*Loader. The preceding restrictions do not apply to Oracle SQL*Loader in most cases. The following restrictions apply to a control file used in a direct path load:
• Multiple table loads are not supported. That is, only one INTO TABLE clause may be specified in the control file.
• SQL expressions may not be used in the data field definitions of the INTO TABLE clause.
• To run a direct path load, add the DIRECT=TRUE option as shown by the following example:
In addition, the APPEND clause must be specified in the control file used by each EDB*Loader session.To run a parallel direct path load, run EDB*Loader in a separate session for each participant of the parallel direct path load. Invocation of each such EDB*Loader session must include the DIRECT=TRUE and PARALLEL=TRUE parameters.Note: In a parallel direct path load, each EDB*Loader session reserves a fixed number of blocks in the target table in a round-robin fashion. Some of the blocks in the last allocated chunk may not be used, and those blocks remain uninitialized. A subsequent use of the VACUUM command on the target table may show warnings regarding these uninitialized blocks such as the following:Indexes on the target table are not updated during a parallel direct path load and are therefore marked as invalid after the load is complete. You must use the REINDEX command to rebuild the indexes.Note: If you attempt a parallel direct path load on the sample emp table provided with Advanced Server, you must first remove the triggers and constraints referencing the emp table. In addition the primary key column, empno, was expanded from NUMBER(4) to NUMBER in this example to allow for the insertion of a larger number of rows.The APPEND clause must be specified in the control file for a parallel direct path load.The following shows the invocation of EDB*Loader in the first session. The DIRECT=TRUE and PARALLEL=TRUE parameters must be specified.Note: user_indexes is the view of indexes compatible with Oracle databases owned by the current user.Queries on the emp table will not utilize the index unless it is rebuilt using the REINDEX command as shown by the following:
2.7 Remote LoadingEDB*Loader supports a feature called remote loading. In remote loading, the database containing the table to be loaded is running on a database server on a different host than from where EDB*Loader is invoked with the input data source.
• The edbldr program must be installed on the client host on which it is to be invoked with the data source for the EDB*Loader session.
• The control file must contain the clause INFILE 'stdin' so you can pipe the data directly into EDB*Loader’s standard input. See Section 2.3 for information on the INFILE clause and the EDB*Loader control file.
•
• When invoking EDB*Loader, use the -h option to specify the IP address of the remote database server. See Section 2.4 for information on invoking EDB*Loader.
• Use the operating system pipe operator (|) or input redirection operator (<) to supply the input data to EDB*Loader.The following example loads a database running on a database server at 192.168.1.14 using data piped from a source named datasource.
To use EDB*Loader to update a table, the table must have a primary key. Please note that you cannot use EDB*Loader to UPDATE a partitioned table.To perform an UPDATE, use the same steps as when performing a conventional path load:
1.
2. Define a control file that uses the INFILE keyword to specify the name of the data file. For information about building the EDB*Loader control file, see Section 2.3.
3. The following example uses the emp table that is distributed with the Advanced Server sample data. By default, the table contains:The following control file (emp_update.ctl) specifies the fields in the table in a comma-delimited list. The control file performs an UPDATE on the emp table:The data that is being updated or inserted is saved in the emp_update.dat file. emp_update.dat contains:Invoke EDB*Loader, specifying the name of the database (edb), the name of a database superuser (and their associated password) and the name of the control file (emp_update.ctl):After performing the update, the emp table contains:The rows containing information for the three employees that are currently in the emp table are updated, while rows are added for the new employees (BAKER and MILLS)
3 EDB*WrapIf you wrap a CREATE PACKAGE statement, you hide the package API from other developers. You may want to wrap the package body, but not the package header so users can see the package prototypes and other public variables that are defined in the package body. To allow users to see what prototypes the package contains, use EDBWrap to obfuscate only the CREATE PACKAGE BODY statement in the edbwrap input file, omitting the 'CREATE PACKAGE' statement. The package header source will be stored plaintext, while the package body source and package functions and procedures will be stored obfuscated.The entire source file is wrapped into one unit. Any psql meta-commands included in the wrapped file will not be recognized when the file is executed; executing an obfuscated file that contains a psql meta-command will cause a syntax error. edbwrap does not validate SQL source code - if the plaintext form contains a syntax error, edbwrap will not complain. Instead, the server will report an error and abort the entire file when you try to execute the obfuscated form.
EDB*Wrap is a command line utility; it accepts a single input source file, obfuscates the contents and returns a single output file. When you invoke the edbwrap utility, you must provide the name of the file that contains the source code to obfuscate. You may also specify the name of the file where edbwrap will write the obfuscated form of the code. edbwrap offers three different command-line styles. The first style is compatible with Oracle's wrap utility:The iname=input_file argument specifies the name of the input file; if input_file does not contain an extension, edbwrap will search for a file named input_file.sqlThe oname=output_file argument (which is optional) specifies the name of the output file; if output_file does not contain an extension, edbwrap will append .plb to the name.If you do not specify an output file name, edbwrap writes to a file whose name is derived from the input file name: edbwrap strips the suffix (typically .sql) from the input file name and adds .plb.edbwrap offers two other command-line styles that may feel more familiar:Once edbwrap has produced a file that contains obfuscated code, you typically feed that file into the PostgreSQL server using a client application such as edb-psql. The server executes the obfuscated code line by line and stores the source code for SPL and PL/pgSQL programs in wrapped form.The following sequence demonstrates edbwrap functionality.First, create the source code for the list_emp procedure (in plaintext form):You can view the plaintext source code (stored in the server) by examining the pg_proc system table:When you use pg_dump to back up a database, wrapped programs remain obfuscated in the archive file.CREATE [OR REPLACE] TYPE type_name AS OBJECTCREATE [OR REPLACE] TYPE BODY type_name
The Dynamic Runtime Instrumentation Tools Architecture (DRITA) allows a DBA to query catalog views to determine the wait events that affect the performance of individual sessions or the system as a whole. DRITA records the number of times each event occurs as well as the time spent waiting; you can use this information to diagnose performance problems. DRITA offers this functionality, while consuming minimal system resources.DRITA compares snapshots to evaluate the performance of a system. A snapshot is a saved set of system performance data at a given point in time. Each snapshot is identified by a unique ID number; you can use snapshot ID numbers with DRITA reporting functions to return system performance statistics.
Advanced Server's postgresql.conf file includes a configuration parameter named timed_statistics that controls the collection of timing data. The valid parameter values are TRUE or FALSE; the default value is FALSE.This is a dynamic parameter which can be modified in the postgresql.conf file, or while a session is in progress. To enable DRITA, you must either:After modifying the timed_statistics parameter, take a starting snapshot. A snapshot captures the current state of each timer and event counter. The server will compare the starting snapshot to a later snapshot to gauge system performance.Use the edbsnap() function to take the beginning snapshot:
4.2 DRITA FunctionsYou can use DRITA functions to gather wait information and manage snapshots. DRITA functions are fully supported by Advanced Server 10 whether your installation is made compatible with Oracle databases or is made in PostgreSQL-compatible mode.4.2.1 get_snaps()The get_snaps() function returns a list of the current snapshots. The signature is:The following example demonstrates using the get_snaps() function to display a list of snapshots:4.2.2 sys_rpt()The sys_rpt() function returns system wait information. The signature is:top_n represents the number of rows to returnThis example demonstrates a call to the sys_rpt()function:
4.2.3 sess_rpt()The sess_rpt() function returns session wait information. The signature is:beginning_id is an integer value that represents the beginning session identifier.top_n represents the number of rows to returnThe following example demonstrates a call to the sess_rpt()function:
4.2.4 sessid_rpt()The sessid_rpt() function returns session ID information for a specified backend. The signature is:beginning_id is an integer value that represents the beginning session identifier.The following code sample demonstrates a call to sessid_rpt():
4.2.5 sesshist_rpt()The sesshist_rpt() function returns session wait information for a specified backend. The signature is:snapshot_id is an integer value that identifies the snapshot.session_id is an integer value that represents the session.The following example demonstrates a call to the sesshist_rpt()function:Note: The following output has been shortened as over 1300 rows were actually generated.
4.2.6 purgesnap()The purgesnap() function purges a range of snapshots from the snapshot tables. The signature is:A call to the get_snaps() function after executing the example shows that snapshots 6 through 9 have been purged from the snapshot tables:4.2.7 truncsnap()Use the truncsnap() function to delete all records from the snapshot table. The signature is:A call to the get_snaps() function after calling the truncsnap() function shows that all records have been removed from the snapshot tables:
The functions described in this section return information comparable to the information contained in an Oracle Statspack/AWR (Automatic Workload Repository) report. When taking a snapshot, performance data from system catalog tables is saved into history tables. The reporting functions listed below report on the differences between two given snapshots.The reporting functions can be executed individually or you can execute all five functions by calling the edbreport() function.4.3.1 edbreport()The edbreport() function includes data from the other reporting functions, plus additional system information. The signature is:beginning_id is an integer value that represents the beginning session identifier.ending_id is an integer value that represents the ending session identifier.The call to the edbreport() function returns a composite report that contains system information and the reports returned by the other statspack functions.The information displayed in the Top 10 Relations by pages section includes:
The information displayed in the Top 10 Indexes by pages section includes:
The information displayed in the Top 10 Relations by DML section includes:
The information displayed in the DATA from pg_stat_database section of the report includes:
The information displayed in the DATA from pg_buffercache section of the report includes:
Note: In order to obtain the report for DATA from pg_buffercache, the pg_buffercache module must have been installed in the database. Perform the installation with the CREATE EXTENSION command.For more information on the CREATE EXTENSION command please see the PostgreSQL Core documentation at:The information displayed in the DATA from pg_stat_all_tables ordered by seq scan section includes:
The information displayed in the DATA from pg_stat_all_tables ordered by rel tup read section includes:
The information displayed in the Data from pg_statio_all_tables section includes:
The information displayed in the DATA from pg_stat_all_indexes section includes:
The information displayed in the DATA from pg_statio_all_indexes section includes:
The information displayed in the System Wait Information section includes:
The information displayed in the Database Parameters from postgresql.conf section includes:
4.3.2 stat_db_rpt()beginning_id is an integer value that represents the beginning session identifier.ending_id is an integer value that represents the ending session identifier.The following example demonstrates the stat_db_rpt() function:The information displayed in the DATA from pg_stat_database section of the report includes:
4.3.3 stat_tables_rpt()beginning_id is an integer value that represents the beginning session identifier.ending_id is an integer value that represents the ending session identifier.top_n represents the number of rows to return
• SYS indicates that the function should return information about system defined tables. A table is considered a system table if it is stored in one of the following schemas: pg_catalog, information_schema, or sys.
• USER indicates that the function should return information about user-defined tables.
• ALL specifies that the function should return information about all tables.The stat_tables_rpt() function returns a two-part report. The first portion of the report contains:The information displayed in the DATA from pg_stat_all_tables ordered by seq scan section includes:
The information displayed in the DATA from pg_stat_all_tables ordered by rel tup read section includes:
4.3.4 statio_tables_rpt()beginning_id is an integer value that represents the beginning session identifier.ending_id is an integer value that represents the ending session identifier.top_n represents the number of rows to return
• SYS indicates that the function should return information about system defined tables. A table is considered a system table if it is stored in one of the following schemas: pg_catalog, information_schema, or sys.
• USER indicates that the function should return information about user-defined tables.
• ALL specifies that the function should return information about all tables.The statio_tables_rpt() function returns a report that contains:The information displayed in the Data from pg_statio_all_tables section includes:
4.3.5 stat_indexes_rpt()beginning_id is an integer value that represents the beginning session identifier.ending_id is an integer value that represents the ending session identifier.top_n represents the number of rows to return
• SYS indicates that the function should return information about system defined tables. A table is considered a system table if it is stored in one of the following schemas: pg_catalog, information_schema, or sys.
• USER indicates that the function should return information about user-defined tables.
• ALL specifies that the function should return information about all tables.The stat_indexes_rpt() function returns a report that contains:The information displayed in the DATA from pg_stat_all_indexes section includes:
4.3.6 statio_indexes_rpt()beginning_id is an integer value that represents the beginning session identifier.ending_id is an integer value that represents the ending session identifier.top_n represents the number of rows to return
• SYS indicates that the function should return information about system defined tables. A table is considered a system table if it is stored in one of the following schemas: pg_catalog, information_schema, or sys.
• USER indicates that the function should return information about user-defined tables.
• ALL specifies that the function should return information about all tables.The statio_indexes_rpt()function returns a report that contains:The information displayed in the DATA from pg_statio_all_indexes report includes:
Checkpoint waits may indicate that checkpoint parameters need to be adjusted, (checkpoint_segments and checkpoint_timeout).
The server has waited for the short-term lock that prevents simultaneous CREATE TABLESPACE or DROP TABLESPACE commands. When wait events occur for lightweight locks, they are displayed by DRITA as well. A lightweight lock is used to protect a particular data structure in shared memory.Certain wait events can be due to the server process waiting for one of a group of related lightweight locks, which is referred to as a lightweight lock tranche. Individual lightweight lock tranches are not displayed by DRITA, but their summation is displayed by a single event named other lwlock acquire.For a list and description of lightweight locks displayed by DRITA, please see Section 28.2, The Statistics Collector in the PostgreSQL core documentation available at:Under Section 28.2.2. Viewing Statistics, the lightweight locks are listed in Table 28-4 wait_event Description where the Wait Event Type column designates LWLock.The following example displays lightweight locks ProcArrayLock, CLogControlLock, WALBufMappingLock, and XidGenLock.These Advanced Server feature specific wait events and the other lwlock acquire event are listed in the following table.
The PostgreSQL 8.3, 8.4, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 10, and 11 Documentation provided the baseline for the portions of this guide that are common to PostgreSQL, and is hereby acknowledged:Portions of this EnterpriseDB Software and Documentation may utilize the following copyrighted material, the use of which is hereby acknowledged.PostgreSQL is Copyright © 1996-2018 by the PostgreSQL Global Development Group and is distributed under the terms of the license of the University of California below.Postgres95 is Copyright © 1994-5 by the Regents of the University of California.THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS-IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.