Hi, Jamie.
Allen, For the OP to stand a better chance of mapping from Oracle (or
any other SQL implementation) to Jet, you could've picked some Jet DDL
types which are closer to Standard SQL <g>:
Jamie, please don't offer advice to others about Oracle SQL without first
checking Oracle documentation.
TEXT(30) would be NVARCHAR(30) or VARCHAR(30)
Trained Oracle professionals haven't used NVARCHAR or VARCHAR in more years
than I can remember. These data types have been deprecated in every major
version of Oracle since either the ANSI SQL-89 or ANSI SQL-92 standards were
published. (I don't know which of these ANSI standards defined them, but
perhaps someone else has this documentation.)
The reason for this deprecation is that these two data types were defined by
ANSI standards after many database engines had been on the market for years,
including Oracle's. Oracle's pre-ANSI definitions were different, so Oracle
had to redefine its versions of these data types to match the ANSI
standards. Oracle's NVARCHAR2 and VARCHAR2 data types are equivalent to the
ANSI NVARCHAR and VARCHAR data types, respectively. Oracle still has the
old NVARCHAR and VARCHAR data types for backwards compatibility, but since
the definitions are different, don't expect Oracle to always handle them the
same as SQL Server would.
CURRENCY would be NUMERIC(19, 5)
That's an ANSI SQL data type and an Oracle 10g NUMBER subtype, but many
Oracle installations are still using earlier versions of Oracle, so the
NUMERIC subtype is not available to them. For Oracle 10g, a trained Oracle
professional uses NUMBER(p,s) for accuracy, but uses DECIMAL(p,s) for speed.
(Where p is the number of significant digits required, and s is the scale
for decimal numbers for the currency -- generally 2 for U.S. dollars, but
occasionally 3, such as when tenths of a cent for gasoline prices are being
stored.) For earlier versions of Oracle, trained Oracle professionals
merely use the NUMBER(p,s) syntax. Please see the following Web page for a
reference to Oracle 10g data types:
http://www.psoug.org/reference/datatypes.html
Please see the following Web page for a reference to Oracle 9i data types:
http://www.ucs.louisiana.edu/~oracle9i/server.901/a90125/sql_elements2.htm
I'm sure you use SQL Server more often than you use Oracle, so it's easy to
confuse SQL Server data types with Oracle data types. Please refer to the
"Mapping Data Types from SQL Server to Oracle" table of the following Web
page for the equivalent data types:
http://msdn2.microsoft.com/en-US/library/ms151738.aspx
YESNO would be... well, SQL-92 doesn't have a 'boolean' data type
(three value logic and all that)
Even if ANSI SQL doesn't offer the boolean data type, Oracle PL/SQL does, so
it's possible (although very unlikely) that Pat's Oracle scripts use
booleans.
so the best for portability would be
col_name INTEGER DEFAULT 0 NOT NULL, CHECK (col_name IN (0, 1))
First, one should _never_ create a table constraint without naming it,
because the database engine will assign a name to it, a name that may be
difficult to determine programmatically. (Perhaps you can offer the syntax
to those Access developers who made the mistake of following your advice, in
order to determine this database-generated constraint name?) The
recommended syntax for a check constraint on such a table as you suggested
is:
CREATE TABLE tblMyTable
(col_name INTEGER DEFAULT 0 NOT NULL,
CONSTRAINT Boolean_CHK CHECK (col_name IN (0, 1)));
.. . . where Boolean_CHK is the name of the check constraint. By creating
the constraint with a name, referencing the data dictionary (if available)
or documentation will allow the database developer to first drop the
constraint if the table needs to be dropped or altered in any way that
affects this constraint. The syntax for dropping this constraint would be:
ALTER TABLE tblMyTable
DROP CONSTRAINT Boolean_CHK;
Also, your syntax doesn't port to Access very easily. It has to be
translated into a VBA procedure that requires the ADODB library, or the
entire Access database must be converted to use SQL Server compatible syntax
(ANSI 92) before using your query's syntax in the SQL View pane. Most
Access developers will just use a Validation Rule and Validation Text, not a
check constraint, to do the job, because it's less work and far more user
friendly.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.