primary key for make-table query

G

Guest

If I follow the instructions below and create a PK from a table created by a
make-table query, will the PK eliminate any duplicate records (ie - only
allow one of each value)?

I want the Customer ID to become the PK, but unfortunately, there are
duplicate PKs in the database I'm pulling data from. Thus, I want the PK to
keep one of each Customer ID, and remove the rest.

Please help!

Patience

(instructions I found to create a PK from a make-table query)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

After you've run the make-table query, run something like this:

ALTER TABLE table_name ADD CONSTRAINT PK_table_name PRIMARY KEY (col1,
col2)

col1 & col2 are the names of the columns that make up the primary key.
You can use only one column if multiple columns are not required.

IOW, you can't designate any attributes during the make-table query to
add a PK.
 
G

Guest

By definition a PK contains no duplicates. If you have duplicate entries of
a Field1 in your new table, then it cannot be a PK.
You must ensure your make-table query selects unique values of the Customer
ID field. One way of doing this is by adding the predicate "DISTINCT" to the
Make-table query.

HTH
Hafeez Esmail
 
M

[MVP] S.Clark

If there are already dup records in the table, then trying to add the PK
will fail.

If the PK is there, and you try to add dup records, then the dups will not
be written.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top