Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 14 days ago.
Improve this question
I am trying to use Postgres with Django application.
I am using pgAdmin to manage Postgres database.
But I can't add new item to database using pgAdmin manually.
Once I typed data manually and clicked the save button, I got
ERROR: invalid input syntax for type uuid: "111"
LINE 3: '111'::uuid, 'asdfasdfdasf'::character varying)
^
Schema is just simple.
Just id and name in the table.
Please help me to fix the issue.
Thank you.
Try to add a default auto-generated value for your id field with the following commands:
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
ALTER TABLE public.table_name
ALTER COLUMN "id" SET DEFAULT uuid_generate_v4();
After that, you need to populate only the name column.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Iam just trying to rename the column in my table.
Column name: AGGREGATE_ID
Data type name: CHARACTER
Length: 15
ALTER TABLE 'headers' CHANGE 'aggregate_id' 'ENGINE' char(15)
I always get the error masssage
"ALTER TABLE 'headers' CHANGE 'aggregate_id' 'ENGINE'char(15)
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "ALTER TABLE 'headers' CHANGE 'agg" was found
following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<create_variable>". SQLSTATE=42601"
I dont know what to do anymore :(
In Db2, renaming a column as ALTER TABLE is done like this:
ALTER TABLE "headers" RENAME COLUMN "aggregate_id" TO ENGINE
If you use double quotes around an identifier, it is stored as provided. If you don't use the quotes, the string is converted to uppercase. Hence I did not use quotes for ENGINE.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want set my collation in postgresql with pgadmin3:
how do see a list list of local collation names in Ubuntu?
How do I set the collation in PgAdmin-III?
I want set Persian collation for my database in Ubuntu
(I know how to create collation in pgadmin , but i don't know how to set this for my database?)
To list all locales on Ubuntu you can use locale -a. The linked page also shows how to configure locales.
AFAIK collation support in glibc is part of the locale/encoding configuration.
You can't alter the collation of an existing database safely or easily, because indexes etc would become suddenly invalid. To set the collation when creating a new database on an existing instance of PostgreSQL use:
CREATE DATABASE somedb
TEMPLATE template0
ENCODING = 'UTF-8'
LC_COLLATE = 'fa_IR'
LC_CTYPE='fa_IR.UTF-8';
You can dump your existing DB then reload to this one.
I don't recommend trying to change the default encoding / locale of a DB on Ubuntu; you'd have to pg_dropcluster the db, then pg_createcluster a new one with different settings. Just CREATE DATABASE with appropriate settings.
I have no idea what you mean with (2), how to "set the collation in PgAdmin-III".
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I create tables with data studio but when I try to access that table from java application, or db2 command console, I get -204 which means the object that I am trying to access is not defined. But in fact it is defined, because I am able to list the tables in db2 command console, but I am not able to select or insert into that table. Please help me if possible. I've already spent 1.5 day on this.
Let's suppose you are using the johndoe user.
How are you creating the tables?
create table myTable (col1 int)
Or like this
create table myschema.myTable (col1 int)
The first table will be created in the catalog as follow:
johndoe.myTable
The second one as
myschema.myTable
As you can see, if no schema is specified, the username will be used as schema.
You can check the tables currently created in db2 with this query
select varchar(tabschema,20), varchar(tabname, 20)
from syscat.tables
where tabschema not like 'SYS%'
In this way you will know what exist in the database.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
How could update the old row's value when I alter table add column default value
type smallint NOT NULL DEFAULT 0
but old rows is still null, Why can't update to default value automatic?
Issue an update statement prior to the alter table statement in your transaction:
update table set col = 0 where col is null
Alter table won't update the data because it's not its job or responsibility; updating is update's job. (The only exception I'm aware is when you change a column's type, in which case you can toss in a using clause to transform the data as you need.)
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Is there any drawback to not having a primary key for a table in Postgres? Since all data is stored unordered in the heap anyway, is the primary key just a way to enforce a unique key and an index at the same time? Or is there a fundamental feature that a primary key provides in a table as opposed to a table that does not have a primary key?
Per the Postgres documentation (http://www.postgresql.org/docs/9.2/static/sql-createtable.html):
Technically, PRIMARY KEY is merely a combination of UNIQUE and NOT
NULL, but identifying a set of columns as primary key also provides
metadata about the design of the schema, as a primary key implies that
other tables can rely on this set of columns as a unique identifier
for rows.
From my experience, I have created plenty of tables without them. But some replication solutions require there be a primary key, or at the single column identifier per row.