Americas

  • United States

Tighter integration between Access and MySQL

Opinion
Jan 19, 20042 mins
Enterprise ApplicationsMySQL

* Dr. Internet columnist Steve Blass helps a reader set the keys in MySQL so Access users can use the database without being prompted

We successfully exported a set of Access database tables to a MySQL database using Open Database Connectivity. Queries work, but when we open a table from Access, we are prompted to select the primary key field(s). Can we set the keys in MySQL so Access users can use the database without being prompted?

After reading your Dec. 1 column (https://www.nwfusion.com/columnists/2003/1201internet.html), we successfully exported a set of Access database tables to a MySQL database using Open Database Connectivity. Queries work, but when we open a table from Access, we are prompted to select the primary key field(s). Can we set the keys in MySQL so Access users can use the database without being prompted?

MySQL (https://www.mysql.com/) can add the key definitions to a table with the ALTER TABLE command.

The statement “ALTER TABLE example ADD PRIMARY KEY (name)” will establish the ‘name’ column value as the primary key for the table called ‘example.’ Multiple column names separated by commas may be listed in parentheses to specify composite keys.

The MySQL command-line client, or the MySQL Control Center (https://www.mysql.com/products/mysqlcc/index.html) application can be used to connect to the database and execute the ALTER TABLE command.

On initial start-up, the MySQL Control Center presents a database server dialog that asks you to identify a database server. After completing this dialog, the server is listed in a MySQL Servers tree. Double-click the server name to establish a connection. Then choose Query from the File menu to open a query editor. Type the ALTER TABLE command in the editor, and choose the “Execute” command and your keys should be permanently set.