I have 2 tables, for example:
table X, columns:
A integer
B string
C number
table X2, columns:
A integer
C number
how to copy contents of X
to X2
(excluding the missing columns) in Tarantool?
tried, but didn't work:
INSERT INTO "X2" SELECT "A", "C" FROM "X"
SELECT "A", "C" INTO "X2" FROM "X"
(version used: 2.6.2)
What kind of error do you get? I don't have 2.6.2 at hand, but when I try on 2.7.0 everything works just fine:
tarantool> \set language sql
tarantool> \set delimiter ;
tarantool> CREATE TABLE x (col1 INTEGER PRIMARY KEY, col2 VARCHAR(20), col3 INTEGER);
tarantool> CREATE TABLE x2 (col1 INTEGER PRIMARY KEY, col2 INTEGER);
tarantool> INSERT INTO x VALUES (1, 'a', 10), (2, 'b', 20), (3, 'c', 30);
tarantool> SELECT * FROM x;
---
- metadata:
- name: COL1
type: integer
- name: COL2
type: string
- name: COL3
type: integer
rows:
- [1, 'a', 10]
- [2, 'b', 20]
- [3, 'c', 30]
...
tarantool> SELECT * FROM x2;
---
- metadata:
- name: COL1
type: integer
- name: COL2
type: integer
rows: []
...
tarantool> INSERT INTO x2 SELECT col1, col3 FROM x;
tarantool> SELECT * FROM x2;
---
- metadata:
- name: COL1
type: integer
- name: COL2
type: integer
rows:
- [1, 10]
- [2, 20]
- [3, 30]
...