![]() ![]() You can change it using one of the following statements:ĪLTER TABLE orderdetails MODIFY COLUMN orderLineNumber smallint(6) AFTER quantityOrdered ĪLTER TABLE orderdetails CHANGE COLUMN orderLineNumber smallint(6) AFTER quantityOrdered So what do you do if you'd like columns to appear in a different order than they were created? AS I alluded to earlier, you don't have to keep a column's original ORDINAL_POSITION. In Navicat, the Table Designer has Move Up and Move Down buttons that make changing column ordering a snap:Īfter selecting the orderLineNumber column, every click of the Move Up button changes its ORDINAL_POSITION by one place:Īfter saving the table design, the orderLineNumber is now before the priceEach: Referencing ORDINAL_POSITION in SELECT Queries The above statements move the orderLineNumber column from last position to second-last. ![]() Rather than spell out each column name in the ORDER BY clause, we can simply refer to the column's ORDINAL_POSITION within the table: To illustrate, here's a query that references a couple of columns in the ORDER BY clause: Ordinal Positioning is not just about default column ordering, it can also be referenced in SELECT queries as a short-cut for column names. In today's blog, we learned how the ORDINAL_POSITION affects a column's location in terms of ordering within a table or query output, as well as how to use ordinal positioning to present columns in our preferred order. ![]()
0 Comments
Leave a Reply. |