# So you do not have to create a database with your role name
psql -U Username DatabaseName
psql -d template1
# if your database is different as your login name you must add the database name
psql -U Username DatabaseName
It appears that your package manager failed to create the database named $user for you. The reason that
psql -d template1
works for you is that template1 is a database created by postgres itself, and is present on all installations. You are apparently able to log in to template1, so you must have some rights assigned to you by the database. Try this at a shell prompt:
createdb
and then see if you can log in again with
psql -h localhost
If the field is already a string, this will work
SELECT RIGHT('000'+ISNULL(field,''),3)
If you want nulls to show as '000'
It might be an integer -- then you would want
SELECT RIGHT('000'+CAST(field AS VARCHAR(3)),3)
Code Example |
---|
Sql :: dateadd in sql |
Sql :: sql select second max |
Sql :: psql get table data types |
Sql :: postgres check for foreign key |
Sql :: is not numeric sql |
Sql :: sql cheat sheet pdf |
Sql :: set id count mysql |
Sql :: rename database in sql |
Sql :: SQL CREATE UNIQUE INDEX for Unique Values |
Sql :: renombrar tabla mysql |
Sql :: vbscript connect mssql |
Sql :: add column in sql server |
Sql :: current date sql |
Sql :: sql function |
Sql :: ms sql print from new line |
Sql :: inner join update |
Sql :: how to show index type in postgresql |
Sql :: SQL Auto Increment Primary Key - PostgreSQL |
Sql :: how to transfer pandas datafra,e to sqlite |
Sql :: kill a pid redshift |
Sql :: mysql backup table |
Sql :: jwt laravel |
Sql :: view databases in mysql |
Sql :: What is dialect for Postgres |
Sql :: mysql check if lowercase |
Sql :: primary key multiple |
Sql :: create user mariadb |
Sql :: mysql if condition |
Sql :: mysql stored procedure vs function |
Sql :: postgress connection refused |