Alter Columns in a Table 
Author Message
 Alter Columns in a Table

Hi Group - can someone please verify my procdure to alter this table ?
I'm a bit nervous about doing this and I'd like to make sure it is
correct:

acronyms=# \d acronyms
                                 Table "mytable"
 Column  |         Type          |                   Modifiers
---------+-----------------------+------------------------------------------------
 id      | integer               | not null default
nextval('acronyms_seq'::text)
 acry    | character varying(40) | not null
 titl    | text                  | not null
 urll    | text                  |
 expl    | text                  |
 acry_f  | character varying(40) |
 title_f | character varying(40) |
 expl_f  | character varying(40) |
Primary key: acronyms_pkey
Unique keys: acronyms_acry_key

I'd like to:
change acry and titl to NULL
change title_f and expl_f to text type

Here's what I would do:

create table tmp as select * from mytable;
drop table mytable;
create table "mytable" (
        "id" integer DEFAULT nextval('mytable_seq'::text) NOT NULL,
        "acry" character varying(40),
        "titl" text,
        "urll" text,
        "expl" text,
        "acry_f" character varying(40),
        "title_f" text,
        "expl_f" text,
        Constraint "mytable_pkey" Primary Key ("id")
);
insert into mytable * from tmp;
drop table tmp;

Thanks, dave



Tue, 21 Jun 2005 23:19:21 GMT
 
 [ 1 post ] 

 Relevant Pages 

1. Altering columns in a Table

2. Alter Column in a table

3. Alter column on big table

4. Altering columns with replicated tables

5. alter column on replicated table

6. ALTER TABLE ... ALTER COLUMN IDENTITY

7. Alter table alter column text

8. ALTER TABLE/ALTER COLUMN problem with MS Access 2K

9. alter table alter column

10. Help with Alter Table Alter Column

11. Alter table Alter column problem.

12. syntax for ALTER TABLE ALTER COLUMN DEFAULT


 
Powered by phpBB® Forum Software