'alter' is a SQL keyword used to change or modify the table structure or the records in a table.
Questions tagged [alter]
835 questions
4
votes
2 answers
SQL - Running multiple ALTER queries
i'm having trouble with running multiple ALTER commands in a single query.
Whenever im trying to run the following code :
ALTER TABLE Book$
ALTER COLUMN PID INT NOT NULL
ALTER TABLE Book$
ADD CONSTRAINT pk_book PRIMARY KEY(PID)
I get an error…

VladM93
- 43
- 1
- 4
4
votes
2 answers
redshift alter udf change owner
In order to drop a user in redshift, I have to change all privileges and ownership of this user.
The user however also owns user defined function in redshift.
How to change the owner of this user-defined-function?
[ ALTER FUNCTION f_.. OWNER TO xyz…

R.Zieglt
- 59
- 4
4
votes
2 answers
How do I alter a trigger in Oracle?
I am trying to change the trigger script for my database. My trigger name is ARCH_USER_UPD_TRG and this puts any updates or deletes on the USER table into a Z_USER table
I am dropping a column from the USER table and now need to modify the trigger…

user906153
- 1,218
- 8
- 30
- 43
4
votes
2 answers
Django create/alter tables on demand
I've been looking for a way to define database tables and alter them via a Django API.
For example, I'd like to be write some code which directly manipulates table DDL and allow me to define tables or add columns to a table on demand…

Joe J
- 9,985
- 16
- 68
- 100
4
votes
1 answer
Oracle 11g - add new column and set as unique
I am facing a problem on how to set a new column to unique using Oracle 11g.
I try to use this code but it getting error:
ALTER TABLE QAS_ASSIGNED_STATE ADD UNIQUE (cuid);

Fai Zal Dong
- 323
- 6
- 25
4
votes
5 answers
Why alter command is referred as DDL and not DML?
I was going through the different commands in SQL and I came across alter command which is referred as DDL (Data Definition Language). We can alter the column and values in it, so we can manipulate the data with this command so why does alter…

Lakshaya Maheshwari
- 492
- 7
- 15
4
votes
3 answers
rename sequence in other schema with same currval
I need to rename bunch of sequences in another schema.
RENAME old_seq to new_seq doesnt work.
Tried:
ALTER SEQUENCE old_seq RENAME TO new_seq;
but it gives me error
ORA-02286: no options specified for ALTER SEQUENCE
I do not wish to mention all…

Anu
- 176
- 1
- 3
- 14
4
votes
2 answers
how to alter primary key to set Default value DEFAULT SYS_GUID() in ORACLE
I create table in oracle and I want add auto increment for my primary key
CREATE TABLE "TEST_1"."PERSON"
("ID" NUMBER NOT NULL ENABLE,
"FNAME" VARCHAR2(20 BYTE),
"LNAME" VARCHAR2(20 BYTE),
CONSTRAINT "PERSON_PK" PRIMARY KEY…

noor
- 41
- 1
- 4
4
votes
2 answers
MS Access: adding column if not exist (or try/catch it)
this is an easy question, but I can't find out the solution...
I have to check if a column exists and add it if the test is negative. How can I do with only sql code?
This is the syntax for SQL Server:
IF NOT EXISTS (
SELECT *
FROM …

Piero Alberto
- 3,823
- 6
- 56
- 108
4
votes
1 answer
drop foreign key without name Oracle
I want to ask a very basic question here.
We may/may not name a constraint while creating a table or after creating the table.
Suppose I chose not to name the foreign key constraint.
The table is having no records.
Can I delete the foreign key name…

Raghav
- 195
- 1
- 3
- 6
4
votes
3 answers
MySQL create or alter table
I am using MySQL 5.1 for my database and I'm sending the commands via a Java program (JBDC).
Is there a MySQL command for creating or altering a table?
Let's say I have a following table:
+----------+----------+
| column_a | column_b…

Limeth
- 513
- 6
- 16
4
votes
3 answers
How do I rename column in w3schools sql?
I am trying to rename a column name in w3schools website
ALTER TABLE customers
RENAME COLUMN contactname to new_name;
However, the above code throws syntax error. What am I doing wrong?

Chibak
- 233
- 1
- 3
- 9
3
votes
2 answers
Remove CHARACTER SET UNICODE_FSS from a column in a firebird database
I have a Firebird database with several tables in it. There are several columns who were added when database was created as
alter table Machines add MachineVersion varchar(100) CHARACTER SET UNICODE_FSS
I want to modify these columns to drop the…

Dan
- 77
- 6
3
votes
2 answers
Changing multiple column names in a mysql table
I have many columns in a table with a name starting with field_t and I have to change that to field_c
For example, here is the ALTER TABLE statement for changing the name of one of the columns:
ALTER TABLE my_table CHANGE field_t_class field_c_class…

rfc1484
- 9,441
- 16
- 72
- 123
3
votes
1 answer
MySQL alter table generating "error on rename"
Here's a print of my error:
mysql> ALTER TABLE Price DROP FOREIGN KEY Id
ERROR 1025 (HY000): Error on rename of '.\testdb\Price' to '.\t
estdb\#sql2-bcc-16' (errno: 152)
I've read this page which suggests that the problem may be due to a left-over…

MitchellSalad
- 4,171
- 8
- 23
- 24