我想知道是否可以在docker-compose文件中执行PSQL命令。
我有以下内容docker-compose.yml:
version: '3'
services:
postgres:
image: postgres:9.6
container_name: postgres-container
ports:
- "5432:5432"
network_mode: host
environment:
- LC_ALL=C.UTF-8
- POSTGRES_DB=databasename
- POSTGRES_USER=username
- POSTGRES_PASSWORD=
- POSTGRES_PORT=5432
Run Code Online (Sandbox Code Playgroud)
并且在运行正常之后,我运行以下命令:
docker exec -i postgres-container psql -U username -d databasename < data.sql
这两个步骤工作正常。但是我很想知道是否有可能一步一步。
每当我想运行此命令时。数据库始终是新的,这一点很重要。这就是为什么我不将其保留在a中volume并想要运行此命令的原因。
是否可以运行docker-compose up并同时运行psql命令?
提前致谢!
I have a table that some column have spaces, like this:
Column A
-----------
"text 1"
" text 2"
"text 3 "
" text 4 "
Run Code Online (Sandbox Code Playgroud)
I want to do a select that return those columns with spaces (beginning or end)
" text 2"
"text 3 "
" text 4 "
Run Code Online (Sandbox Code Playgroud)
Is that possible?
After search for them, How could I update those columns to remove the spaces?