I have 2 tables with 2 columns (user_id and year).
Query1:
SELECT * FROM table_1 t1
FULL JOIN table_2 t2 ON t1.user_id=t2.user_id AND t1.year=t2.year
Produces following column names:
user_id, year, user_id_1, year_1
Query2:
CREATE TABLE table_copy AS SELECT * FROM
(SELECT * FROM table_1 t1
FULL JOIN table_2 t2 ON t1.user_id=t2.user_id AND t1.year=t2.year);
Produces following vague column names:
QCSJ_C000000000400000, QCSJ_C000000000400002, QCSJ_C000000000400001, QCSJ_C000000000400003
Is there a short way to force Oracle query2 to use the same names as query1 without writing them explicitly (it is important when there are many columns)? Maybe some Oracle settings?
List your columns and use AS to specify the column name.
e.g.
CREATE TABLE table_copy AS
SELECT t1.user_id AS t1_user_id,
t1.year AS t1_year,
t2.user_id AS t2_user_id,
t2.year AS t2_year
FROM table_1 t1
FULL JOIN table_2 t2 ON t1.user_id=t2.user_id
AND t1.year=t2.year;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With