we have a database which has a table called Students with columns id,name,age,school.
Now i want to write a migration script to copy 3 columns (lets assume i have millions of records) from Students table to New_students table .
Below is my sample script which i have written . It is throwing an error
CREATE TABLE IF NOT EXISTS New_Students (
id PRIMARY KEY,
name string,
age string,
)
INSERT INTO New_Students(id,name,age)
SELECT id,name,age
FROM students;
When executed above in crateDb Admin UI, i get below error
SQLActionException[SQLParseException: line 8:1: mismatched input 'INSERT' expecting <EOF>]
The above statements works when executing individually .
Question:
The SQL console of the CrateDB AdminUI does not support multiple statements.
You could use the crash
CLI tool instead, which does support multiple statements, see https://crate.io/docs/clients/crash/en/latest/.