Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Is the `bigserial` compatible with the `bigint` on Cockroach?
- ### Create the tables
- Let's create **table_x** with a `bigserial` column and set it as the `primary key`.
- ```sql
- CREATE TABLE table_x (
- id bigserial PRIMARY KEY,
- whatever text
- );
- ```
- Now we create the **table_y** but set it's columns to `bigint`, but no `primary key` this time _(this should not interfere in anything)_:
- ```sql
- CREATE TABLE table_y (
- table_x_id bigint,
- whatever text
- );
- ```
- ### load data
- Let's insert some data on the tables and try to compare the values:
- ```sql
- INSERT INTO table_x(id, whatever) values (1000000000009, 'name 1'), (200000000000000009, 'name 2');
- ```
- ```sql
- INSERT INTO table_y(id, whatever) values (1000000000009, 'name 1'), (200000000000000009, 'name 2');
- ```
- ### Compare the values
- ```sql
- select
- id,
- table_x.whatever as whatever,
- (table_x.id = table_y.table_x_id) as is_equal
- from
- table_x as table_x
- left join table_y as table_y
- on table_y.table_x_id = table_x.id
- ```
- Result
- ```
- id | whatever | is_equal
- +--------------------+----------+----------+
- 1000000000009 | name 1 | true
- 200000000000000009 | name 2 | true
- (2 rows)
- Time: 4.427524ms
- ```
- ### Conclusion
- I guess it is safe to say that for LEFT JOINs (and probably the other JOINs as well) both types are compatible.
Add Comment
Please, Sign In to add comment