正在创建的列中查找数据类型 table

Finding data type of columns in created table

我正在尝试为 table 结构的用户验证提供服务,其中一个组件是列数据类型,例如 uuidtext 和 [=16] =] 在下面的“CREATE TABLE”语句中。

USE my_keyspace;
CREATE TABLE users (
    id uuid,
    name text,
    age bigint);

如果我这样做

USE system;
SELECT validator FROM schema_columns
WHERE keyspace_name='my_keyspace' AND columnfamily_name='users';

我明白了

org.apache.cassandra.db.marshal.UUIDType
org.apache.cassandra.db.marshal.UTF8Type
org.apache.cassandra.db.marshal.LongType

这似乎提供了很多信息,但仔细观察后,多个不同的数据类型可以映射到相同的验证器值。有没有办法提取在“CREATE TABLE”语句中输入的数据类型信息,或者至少找到类型之间的一些区别?

此外,我很好奇为什么验证器数据前面有 'org.apache.cassandra...',但找不到解释,所以如果有人知道这是为什么,我会非常感兴趣知道。

Which seems informative, but on closer inspection, multiple distinct datatypes can map to the same validator value.

如果是这种情况,例如 varchar 和 text,我相信数据类型相互映射并且可以互换。如果我错了,其他人会纠正我。

Is there a way I can pull the data type info as entered in the `CREATE TABLE' statement, or at least find some distinction between the types?

我知道的唯一方法是:

DESC TABLE users;

Also, I'm curious as to why the validator data has the 'org.apache.cassandra...' prepended to it, and couldn't find an explanation, so if anybody knows why that is, I'd be very interested to know.

Cassandra 在 Java 中实现,这是实现数据类型的 Class 的完整路径。

更多信息:

http://docs.datastax.com/en/cql/3.0/cql/cql_reference/cql_data_types_c.html

https://github.com/apache/cassandra/tree/trunk/src/java/org/apache/cassandra/db/marshal

使用以下查询:

select column_name,type from system_schema.columns where keyspace_name ='my_keyspace' AND table_name='users';