I have a database I'm creating and I made a 1 to 1 connection with another table in Mysql, below is a screen shot. My question is can I drop the extra column (assembly factory_id) that was created when I made the connection? I only want the single (factory_id) will this mess up the connection that I made? Should i drop the (factory_id) and let the connection stay? I'm a noob, thanks!
2 Answers
You can drop the extra column by using the Alter statement.
ALTER TABLE table_name DROP COLUMN factory_id;
You can also refer to http://docs.oracle.com/cd/E18283_01/server.112/e17118/statements_3001.htm#i2103683 (Drop column clause in particular)
Edit: As far as the connection is concerned, the Alter statement dumps to a temporary table and then rebuilds without losing any connection. Please refer to the section Storage, Performance, and Concurrency Considerations in this document

- 649
- 11
- 24
-
but should i drop the table? thats my question. : ) – beau8008 Apr 01 '15 at 02:19
-
Because I made a 1 to 1 connection it added the extra column, if i get rid of "factory_id" will that change anything? – beau8008 Apr 01 '15 at 02:20
I am assuming that your comment "but should i drop the table?" really meant to say "but should i drop the column?".
Short answer: if it is safe, you should delete the column - there's no reason to keep it cluttering up the database and the minds of future developers.
Long answer: how to determine if it's safe: If 1) the value in factory_id IS and ALWAYS WILL BE identical to assembly factory_id, eg, they are a duplicate value of each other, and 2) no other tables or program code refer to assembly factory_id, you can safely delete assembly factory_id.
However, if there's any chance that they ever mean different things (not just the sample of 20 or so rows), you can't delete it. See fiddle: http://sqlfiddle.com/#!9/0bf17/1
If they are always the same, but parts of the database or the code refer to assembly factory_id, you can refactor those database or code parts to refer to factory_id instead and THEN delete assembly factory_id.
When doing something like this, you should make tests to verify that the state of queries and programs after the change is the same as the state before the change.

- 2,986
- 2
- 24
- 38
-
Thank you so much! thats the answer i needed! and yep, i meant column, not table :) – beau8008 Apr 01 '15 at 20:10