'alter' is a SQL keyword used to change or modify the table structure or the records in a table.
Questions tagged [alter]
835 questions
7
votes
3 answers
Checking Truncate/Alter Permission for a login
How to check whether a login has truncate permission for a particular table?
We have a login called Test for which we have given ALTER permission to particular tables alone. Now I want get the list of tables for which Test login has Alter…

Pரதீப்
- 91,748
- 19
- 131
- 172
7
votes
2 answers
Can I use ALTER DATABASE to rename a mysql database?
I am using PDO with PHP to create a new database and then a new user with privileges on that database. In case one of them fails, I want to rename the database and user so that they can be deleted later and the names are available.
Is it possible to…

Xerri
- 4,916
- 6
- 45
- 54
7
votes
3 answers
ALTER TABLE Sqlite: how to check if a column exists before alter the table?
I need to execute in python a SQL query that adds a new column, in sqlite3.
The problem is that sometimes it already exists. So previous to executing the query I need to check if the column already exists.
If it does, then I won't execute the…

Esabe
- 1,941
- 4
- 16
- 19
7
votes
3 answers
alter column from time with time zone to timestamp
I am having trouble changing a column called end_date in a table called key_request from time with time zone to timestamp in my Postgres database . I have tried using the following code:
alter table key_request alter column end_date type timestamp…

wilty
- 175
- 1
- 1
- 10
6
votes
2 answers
How to undo ALTER TABLE using sqlplus (Oracle 10g Express)?
rollback;
doesn't seem to undo alter table changes.
Background:
I'm generating some .sql scripts (based on parsed Hibernate scripts) which are trashing my tables. Importing the full database for testing takes up to 30 minutes (also slowing my…

glenneroo
- 1,908
- 5
- 30
- 49
6
votes
4 answers
How do you assign a column default in MySQL to another column's value?
I want to add a new column to a table in MySQL database that should get the value of another column in the same table. Is this possible? If so, how do you do it?
Sumit Garg
6
votes
1 answer
SQL Server multiple schema object issues
I have database that has multiple schemas and objects under them. I want to consolidate the objects into one schema.
I tried
ALTER SCHEMA dbo TRANSFER .
I get an
object already exists message
However, I can't see it in…

shikarishambu
- 2,219
- 6
- 35
- 57
6
votes
2 answers
Liquibase "modifyDataType" tag always makes the column nullable
When I do-
In liquibase, it always resets the nullable constraints. Is it possible to add some parameter so it didn't remove the constraints,…

Zatosssas
- 61
- 1
- 4
6
votes
3 answers
Add Primary Key to a table with existing clustered index
I have to work with a database to do reporting
The DB is quite big : 416 055 104 rows
Each row is very light though, just booleans and int ids.
Each row is identify by 3 columns, but at my surprise, there is no Primary Key on it.
Only a Clustered…

Stéphane
- 11,755
- 7
- 49
- 63
6
votes
3 answers
How to alter user defined table types
I have already tried to alter the user defined table types but it is not working with alter commend.
alter TYPE [dbo].[GriDDateTab] AS TABLE(
[Application [varchar](50) NOT NULL,
[LandDist] [char](2) NULL,
[Land] [char](3) NULL,
…

ganesh
- 95
- 1
- 1
- 3
6
votes
2 answers
ERROR 1878 (HY000): Temporary file write failure in mysql
When i am running Alter command in mysql to add a new column to my existing table. I am facing this error.
ERROR 1878 (HY000): Temporary file write failure.
Any idea regarding this? Please guide.
Many Thanks.

asterisk user
- 125
- 4
- 10
6
votes
1 answer
Postgres REASSIGN OWNED for only 1 database
I want to use the REASSIGN OWNED query to change all objects in 1 database from owner A to owner B.
Let say I have the following databases:
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 |…

Carlos Vásquez
- 61
- 1
- 3
5
votes
1 answer
Alter table add column AFTER in derby database
Is there a way in a derby database to add a column after another just like mysql does?

Florian Müller
- 7,448
- 25
- 78
- 120
5
votes
0 answers
MySQL 8.0 Alter Table Algorithm=INSTANT not working as expected (takes 40 secs)
MySQL 8.0 - As stated in MySQL Official Doc and MySQL Server Team, Alter table with Algorithm=INSTANT adds the column instantly without taking any lock.
But, It worked out different.
Test Setup - Table with 40M rows. Reads and writes (1000 TPS) on…

Anoosh
- 105
- 3
- 10
5
votes
2 answers
Add a new column in table with a sequence - Oracle
I have a table that has 60 million rows of data. I would like to introduce a new column say "id" for the table that is an auto incremented sequence.
For example:
CREATE TABLE Persons (
LastName varchar(255),
FirstName varchar(255)
);
INSERT…

ht_3535
- 363
- 3
- 9