Invoke SQL file inside the YB container

Hello,
Below is my docker file and it does now copy the sql file into the container…

docker file
FROM yugabytedb/yugabyte:latest
COPY ./ysqlscript.sql /

ysqlscript.sql
CREATE DATABASE yb_demo;
\c yb_demo;
\i share/schema.sql;
\i share/products.sql
\i share/users.sql
\i share/orders.sql
\i share/reviews.sql

docker run -it yb1
[root@1d3433dcafce scripts]# ls
ysqlscript.sql

but how can I invoke this SQL file inside the ysqlsh?

@dorian_yugabyte @neha

@theNewGuy

You can use the -f flag on ysqlsh to execute a sql file: ysqlsh - YSQL shell for YugabyteDB | YugabyteDB Docs.

Example:

$ ./bin/ysqlsh -f share/schema.sql
$ ./bin/ysqlsh -f share/products.sql

In this case, you need to split the create database into a separate file and run that first.

Note that \c ybdemo; actually drops the current connection and starts a new one.
You can’t do that from the command line, you have to start a new connection, by running ysqlsh again but with different credentials like:

./bin/ysqlsh -c 'create database ybdemo;'
./bin/ysqlsh -d ybdemo -f share/schema.sql

Can mark this as CLOSED. I am good on this. Thanks.