Increase size of the column

Moderator: NorbertKrupa

Post Reply
Jess.mic
Newbie
Newbie
Posts: 15
Joined: Tue Jun 11, 2013 11:02 pm

Increase size of the column

Post by Jess.mic » Wed Sep 18, 2013 9:35 pm

I need to increase the size of the column from varchar(255) to varchar(1000).

What command I will use for that??

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Increase size of the column

Post by JimKnicely » Wed Sep 18, 2013 11:07 pm

Hi,

Use the ALTER TABLE ALTER COLUMN statement.

Example:

Code: Select all

dbadmin=> CREATE TABLE t (c VARCHAR(255));
CREATE TABLE
dbadmin=> \d t;
                                    List of Fields by Tables
 Schema | Table | Column |     Type     | Size | Default | Not Null | Primary Key | Foreign Key 
--------+-------+--------+--------------+------+---------+----------+-------------+-------------
 public | t     | c      | varchar(255) |  255 |         | f        | f           | 
(1 row)

dbadmin=> ALTER TABLE t ALTER COLUMN c SET DATA TYPE VARCHAR(1000);
ALTER TABLE
dbadmin=> \d t;
                                    List of Fields by Tables
 Schema | Table | Column |     Type      | Size | Default | Not Null | Primary Key | Foreign Key 
--------+-------+--------+---------------+------+---------+----------+-------------+-------------
 public | t     | c      | varchar(1000) | 1000 |         | f        | f           | 
(1 row)
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Jess.mic
Newbie
Newbie
Posts: 15
Joined: Tue Jun 11, 2013 11:02 pm

Re: Increase size of the column

Post by Jess.mic » Thu Sep 19, 2013 12:12 am

I used the alter table alter column command given by you:-

ALTER TABLE t ALTER COLUMN c SET DATA TYPE VARCHAR(1000);

But it is giving me error. Below is the error:-
'[Vertica][VerticaDSII] (20) An error occurred during query execution: ERROR: syntax error at or near "DATA" at character 93'



The present length of the column is VARCHAR(255) and i want increase it to VARCHAR(1000).

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Increase size of the column

Post by JimKnicely » Thu Sep 19, 2013 6:27 am

Hi,

What version of Vertica are you running? The SET DATA TYPE option was a feature introduced in 6.0.

Check out this old thread:

viewtopic.php?f=5&t=155

I hope this helps!
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “New to Vertica SQL”