The sequence of data columns returned by "select * ..." is wrong
dong524dong opened this issue · comments
Hello, I created the following table:
CREATE TABLE C_KAKOU(C_CPH VARCHAR,C_ID INT,C_NAME VARCHAR,C_TS TIMESTAMP);
But I am executing:
REDISQL.EXEC DB "SELECT * FROM C_KAKOU;"
20 pieces of data are returned, but the order of the columns in the data is out of order:
10) 1) "AB3990"
2) (integer) 10
3) "2019-01-01 00:01:10.0"
4) "jingzhou"
11) 1) "AD3981"
2) (integer) 1
3) "huangshi"
4) "2019-01-01 00:01:01.0"
You can see that the data in the third column and the fourth column have exchanged positions. The data in 11) ~ 20) is in the order of the columns that created the table, but the C_TS column in the data in rows 1) ~ 9) is in the third column. Why is this?
Thank you!
Hi there,
it seems very very weird.
Can you post the database?
Can it be that you have the data swapped in the database?
Cheers,
Simone
You can create a new database backed by a file:
REDISQL.CREATE_DB new test.sqlite
And then copy your db to the new one.
REDISQL.COPY DB new
And now in test.sqlite
there should be your original database.
Another alternative is running:
REDISQL.EXEC DB "SELECT C_TS FROM C_KAKOU;`
And print the result.
I'm very sorry, I don't understand what you mean too much. Could you please guide me in the specific operation?
Can you run this command:
REDISQL.EXEC DB "SELECT C_TS FROM C_KAKOU;"
What is the result?
According to the steps you know, the result of the execution is still the same, and the order of the columns is out of order.
-
- "AB3981"
- (integer) 1
- "2019-01-01 00:01:01.0"
- "jingzhou"
-
- "AB3982"
- (integer) 2
- "2019-01-01 00:01:02.0"
- "jingzhou"
-
- "AB3983"
- (integer) 3
- "2019-01-01 00:01:03.0"
- "jingzhou"
-
- "AB3984"
- (integer) 4
- "2019-01-01 00:01:04.0"
- "jingzhou"
-
- "AB3985"
- (integer) 5
- "2019-01-01 00:01:05.0"
- "jingzhou"
-
- "AB3986"
- (integer) 6
- "2019-01-01 00:01:06.0"
- "jingzhou"
-
- "AB3987"
- (integer) 7
- "2019-01-01 00:01:07.0"
- "jingzhou"
-
- "AB3988"
- (integer) 8
- "2019-01-01 00:01:08.0"
- "jingzhou"
-
- "AB3989"
- (integer) 9
- "2019-01-01 00:01:09.0"
- "jingzhou"
-
- "AB3990"
- (integer) 10
- "2019-01-01 00:01:10.0"
- "jingzhou"
-
- "AD3981"
- (integer) 1
- "huangshi"
- "2019-01-01 00:01:01.0"
-
- "AD3982"
- (integer) 2
- "huangshi"
- "2019-01-01 00:01:02.0"
-
- "AD3983"
- (integer) 3
- "huangshi"
- "2019-01-01 00:01:03.0"
-
- "AD3984"
- (integer) 4
- "huangshi"
- "2019-01-01 00:01:04.0"
-
- "AD3985"
- (integer) 5
- "huangshi"
- "2019-01-01 00:01:05.0"
-
- "AD3986"
- (integer) 6
- "huangshi"
- "2019-01-01 00:01:06.0"
-
- "AD3987"
- (integer) 7
- "huangshi"
- "2019-01-01 00:01:07.0"
-
- "AD3988"
- (integer) 8
- "huangshi"
- "2019-01-01 00:01:08.0"
-
- "AD3989"
- (integer) 9
- "huangshi"
- "2019-01-01 00:01:09.0"
-
- "AD3990"
- (integer) 10
- "huangshi"
- "2019-01-01 00:01:10.0"
Hello,
can you please run this query?
REDISQL.EXEC DB "SELECT C_TS FROM C_KAKOU;"
Note that we are selecting only the C_TS
column, not all.
Thanks,
Simone
After your sorting out, I seriously suspect that my code has a bug when inserting data, thank you very much!
SQLite has dynamic typing for the columns of the database. So the type that you declare is an invite, it is not really a constraint.
Sometimes is very useful, some time can end up in this kind of problem.
Cheers,
Simone
Thank you for your detailed answers. I have located a bug that caused me to be out of order when inserting data. Thanks again!
Great!
I will close the issue.
Aw congrats on opening your first issue on github!