autonumber - How to change the auto numbering id field to serial type in PostgreSQL -


I have a database which is MSSQL to PostgreSQL (9.2) .
This database contains 100+ tables, this is entered in the table Automotoring (primary key field), is an example for the table below

  create table company (company's The integer is not equal to the NAL default ('SEC_company_ID': Regclass), the character of the company is different (100), AD1 character different (100), AD2 character different (100), AD3 character different (100), phone Character Separate (30), Phoneras Character Segmentation (30) Co Certificate Gcompany_pkey Primary key (companyid))  


Sample data

  INSERT (company, add1, add2, add3, phone, phone, phone ) VALUES ('company1', 'add1', 'add2', 'add3', '00, 055,544 ',' 7788,848 '); INSERT Company (Company, AD1, AD2, AD3, PhoneAff, PhoneRace) Value ('Company2', 'AD 9', 'AD5', 'AD2', '00088844', '7458844'); INSERT Company (Company, AD1, AD2, AD3, PhoneAff, PhoneRes) Value ('Company 5', 'Adi5', 'AD8', 'Ad 7', '00099 9 44', '2218844') ;  

and sequence for this table below

  create SEQUENCE seq_company_id INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 cache 1; Optional table seq_company_id for postgres;  

While reading the PostGraceQL document I have read so that I would like to replace all existing Auto Numbering Field serials. How to do this


I have tried

  Changing the company to the table company type serial  

 < Code> error: type "serial" does not exist ********** error *********  

In fact, there is no data type serial . This sequence is just a short notation sign for the default value (see for details), basically what you now have

your setup and a serial The difference between the columns defined in the form is that there is a link between the sequence and column, which you can also define manually:

  Sequence seq_gcompany_id owned by company.companyid;  

With that link, you can no longer separate your columns from the column, which is initially defined as serial . What this change does is, that if the table (or column) is used to drop it, then that order will be automatically deleted


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -