Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsigned field in Amazon Redshift?

I was looking for a way to create a table with unsigned integer (I know I will have only positive integers, so why not to increase the range twofold). To create an integer field, I do:

create table funny_table(
    my_field bigint
);

So I thought that using my_field bigint unsigned will solve my problem, but syntax error tells me otherwise. Looking though the documentation tells nothing about unsigned integers. Is it even possible?

like image 340
Salvador Dali Avatar asked Jan 09 '15 01:01

Salvador Dali


People also ask

What are the limitations of Amazon Redshift?

Amazon Redshift doesn't support tables with column-level privileges for cross-database queries. Amazon Redshift doesn't support concurrency scaling for the queries that read data from other databases. Amazon Redshift doesn't support query catalog objects on AWS Glue or federated databases.

Can primary key be null in Redshift?

Now, the Redshift database will allow only non-null values in the ID column of the notnull_demo_table. You will end up getting an error if the value is NULL.

What is no schema binding in Redshift?

WITH NO SCHEMA BINDING. Clause that specifies that the view isn't bound to the underlying database objects, such as tables and user-defined functions. As a result, there is no dependency between the view and the objects it references. You can create a view even if the referenced objects don't exist.

Does Redshift support unstructured data?

Unstructured data – Data in Amazon Redshift must be structured by a defined schema, rather than supporting arbitrary schema structure for each row. If your data is unstructured, you can perform extract, transform, and load (ETL) on Amazon EMR to get the data ready for loading into Amazon Redshift.


1 Answers

Unfortunately Amazon Redshift doesn't support unsigned integer. As a workaround, we are using numeric(20,0) for bigint unsigned data. Here is an example.

create table funny_table(
    my_field numeric(20, 0)
);
insert into funny_table values ( 18446744073709551614 );
select * from funny_table;
       my_field
----------------------
 18446744073709551614
(1 row)

See here for the details of Numeric type.

like image 141
Masashi M Avatar answered Oct 03 '22 05:10

Masashi M