1 Reply Latest reply on Mar 16, 2016 8:41 PM by Gary Graham-Oracle

    Column alias not displaying when connecting to MySQL

    3199444

      Hey, this is related to: Column alias not displaying when connecting to MySQL

       

      select col_name AS col_alias from table;

      Result stays col_name, also without the AS or with AS "col_alias"

       

      I tested with native and phpmyadmin, both are working fine.

       

      Developer Version: 4.1.3.20.78

      java: 1.8.0_74

      jdbc driver: mysql-connector-java-5.1.38-bin.jar

       

      regards

        • 1. Re: Column alias not displaying when connecting to MySQL
          Gary Graham-Oracle

          Whether or not the column alias is ignored seems to depend on a number of things...

           

          1. The version of the MySQL JDBC driver. A old bug logged against Netbeans noted the problem for 5.1.5 but not 5.0.7.  For reference:

              https://netbeans.org/bugzilla/show_bug.cgi?id=132647

              and

              MySQL Bugs: #21596: column aliases ignored in ResultSetMetaData

           

          2. Whether the column is just a column, or used in an expression.  Using MySQL 5.7 with the 5.1.27 driver against SQL Developer 4.1.3

              This works:     select trim(district) as Zone from city;

                           or:     select district||'' as Zone from city;

           

                    but not:     select district  as Zone from city;

           

          3. The responder in the other discussion looks to have been using an Oracle gateway, not the MySQL driver, so I doubt that's meaningful to us.

           

          So one could suspect SQL Developer needs the same fix as the Netbeans folks made, specifying getColumnLabel instead of getColumnName, but I haven't time to research that.  Moreover, if this ability is not needed to support migration from MySQL to Oracle, any bug would likely be low priority.