Database version: SQLite3
Aqua Data Studio 14.0.0-rc-44
Build #: 34314
Built on: 2013-Oct-03 04:42:13 PM
Windows 7: 64 bit
Step 1: Connect to SQLite.
Step 2: Create a table, with a column having BLOB datatype.
CREATE TABLE "Test_table1" (
"c1" INTEGER NOT NULL,
"c2" BLOB,
"c3" BLOB,
PRIMARY KEY("c1") )
Step 3: Insert a record in table Test_table1
INSERT INTO Test_table1 VALUES(1, x'0500', x'0500').
Step 4: Execute typeof() command on table.
SELECT typeof(c1), typeof(c2), typeof(c3) FROM Test_table1;
This command will give typeof c2 and c3 as ‘blob’ .
Step 5: Right click on Test_table1, in SQLite tree node -> Select ‘Edit Table Data, -> Click on data in column, c2 or c3 of table -> Observe ‘ Value-type’ at the bottom of window.
Value type shown here is ‘String’.
Value type shown in table data editor should be ‘blob’.
|
289 KB
|
308 KB
Since SQLite supports variant data (i.e. data doesn't need to conform to the column's data type), the "value type" in the status bar is based on the data type of the cell value (not the column's data type). In your case, the data is returned as "string" data from SQLite and therefore the "value type" is "string".
I agree with you, in SQLite data doesn't need to conform to the column's data type and status bar in table data editor shows value type of cell value. But, I m still confused, since typeof() command also shows value type in case of SQLite. Consider a scenario where column type is not “blob” and enter blob data.
Step 1: Connect to SQLite.
Step 2: Create table.
CREATE TABLE "table_1" (
"c1" INTEGER NOT NULL,
"c2" TEXT,
"c3" NUMERIC,
"c4" INTEGER,
"c5" ,
PRIMARY KEY("c1") )
GO
Step 3: Insert ‘blob’ data.
INSERT INTO table_1 VALUES(1,x'0500', x'0500', x'0500', x'0500')
GO
Step 4: Execute typeof() command on table.
SELECT typeof(c1), typeof(c2), typeof(c3), typeof(c4), typeof(c5) FROM table_1
GO
Step 5: Right click on table_1, in SQLite tree node -> Select ‘Edit Table Data, -> Click on data in columns, Observe ‘ Value-type’ on the status bar. (Refer image image_2.jpeg)
Value type shown in table data editor status bar is ‘String’ but value type given by typeof() command is ‘Blob’.
I agree with you, in SQLite data doesn't need to conform to the column's data type and status bar in table data editor shows value type of cell value. But, I m still confused, since typeof() command also shows value type in case of SQLite. Consider a scenario where column type is not “blob” and enter blob data.
Step 1: Connect to SQLite.
Step 2: Create table.
CREATE TABLE "table_1" (
"c1" INTEGER NOT NULL,
"c2" TEXT,
"c3" NUMERIC,
"c4" INTEGER,
"c5" ,
PRIMARY KEY("c1") )
GO
Step 3: Insert ‘blob’ data.
INSERT INTO table_1 VALUES(1,x'0500', x'0500', x'0500', x'0500')
GO
Step 4: Execute typeof() command on table.
SELECT typeof(c1), typeof(c2), typeof(c3), typeof(c4), typeof(c5) FROM table_1
GO
Step 5: Right click on table_1, in SQLite tree node -> Select ‘Edit Table Data, -> Click on data in columns, Observe ‘ Value-type’ on the status bar. (Refer image image_2.jpeg)
Value type shown in table data editor status bar is ‘String’ but value type given by typeof() command is ‘Blob’.
As I mentioned in my earlier comment, we use the data returned from SQLite to determine the value type. We don't submit the typeof() SQL function query for every single cell value. Note that for the integer value, typeof() returns "integer" (lowercase integer) as SQLite uses its own internal logic to determine the type for the underlying data, but value type is "Integer" (leading uppercase Integer) in the Table Data Editor because the data is an java.lang.Integer object returned from SQLite.
For blob data, it depends on the setting of File -> Options -> Results -> Convert binary to hex.
- If on, the blob data will be turned into a string of hex digits and the data will be stored in a java.lang.String object. Therefore, value type is "String".
- If off, the blob data will stay as a byte array. Value type is "byte[ ]".
Currently, we use the Java object to determine the data type for SQLite data. For performance reasons, we can't issue separate typeof() queries just to populate the value type. There is no "metadata" to determine the data type of the underlying SQLite data.
We'll consider fixing this inconsistency in the future.
As I mentioned in my earlier comment, we use the data returned from SQLite to determine the value type. We don't submit the typeof() SQL function query for every single cell value. Note that for the integer value, typeof() returns "integer" (lowercase integer) as SQLite uses its own internal logic to determine the type for the underlying data, but value type is "Integer" (leading uppercase Integer) in the Table Data Editor because the data is an java.lang.Integer object returned from SQLite.
For blob data, it depends on the setting of File -> Options -> Results -> Convert binary to hex.
- If on, the blob data will be turned into a string of hex digits and the data will be stored in a java.lang.String object. Therefore, value type is "String".
- If off, the blob data will stay as a byte array. Value type is "byte[ ]".
Currently, we use the Java object to determine the data type for SQLite data. For performance reasons, we can't issue separate typeof() queries just to populate the value type. There is no "metadata" to determine the data type of the underlying SQLite data.
We'll consider fixing this inconsistency in the future.
Issue #10445 |
Closed |
Incomplete |
Completion |
No due date |
No fixed build |
No time estimate |
Since SQLite supports variant data (i.e. data doesn't need to conform to the column's data type), the "value type" in the status bar is based on the data type of the cell value (not the column's data type). In your case, the data is returned as "string" data from SQLite and therefore the "value type" is "string".