I have a table in one database, call this db x. I have another database, call it y. I want to copy data from x.some_table to y.some_table. I don’t want to do an exact copy of the table, because some columns don’t make sense in database b. I use the following query:
INSERT INTO y.some_table (a_field) SELECT a_field FROM x.some_table;
a_filed in both tables is defined as DOULBE(17,0). If i run this:
USE y;
SELECT a_field FROM x;
Then I get output with full values –no floating-point truncation. However, if after insertion using the first query I showed, I get nothing but whole numbers in y’s some_table.a_field. The floating-point remainders are truncated.
What am I doing wrong? Thanks.
Are you sure that the column is defined as DOUBLE(17,0) in both tables? Doesn’t that specify 17 total digits with 0 after the decimal? If so you’re select from table x should also have 0 decimal places. If its defined differently in x say DOUBLE(17,6) and you are trying to insert it into DOUBLE(17,0) then the decimals will be truncated I believe.