Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when I try to create ordered SQL table

I'm trying to create a volatile table in SQL with an ORDER BY and I get an error.

CREATE VOLATILE TABLE orderd_dates AS
(SELECT * FROM date_table
ORDER BY id_date)
with data primary index (id_date) on commit preserve rows;

The error is: ORDER BY is not allowed in subqueries.

If I can't use order by, how can I create a volatile table that's ordered?

like image 891
Jacob Curtis Avatar asked May 13 '26 04:05

Jacob Curtis


1 Answers

SQL tables are inherently unordered. You need to explicitly use an order by clause when querying the table, not when creating it.

like image 114
Mureinik Avatar answered May 15 '26 17:05

Mureinik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!