- PostgreSQL: SERIAL (or BIGSERIAL depending on integer size)
- MS-SQL: IDENTITY(1, 1)
- AUTO_INCREMENT can only be used for integer data types.
- AUTO_INCREMENT columns should be part of an index.
- DEFAULT clausule is not allowed.
Code: Select all
# mySQL :
CREATE TABLE phpbb_presets (
preset_id MEDIUMINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
preset_type VARCHAR(5) NOT NULL DEFAULT '',
preset_name VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY ( preset_id )
);
# postgresql
CREATE SEQUENCE phpbb_presets_id_seq start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
CREATE TABLE phpbb_presets (
preset_id int4 NOT NULL DEFAULT nextval('phpbb_presets_id_seq'::text),
preset_type varchar(5) NOT NULL DEFAULT '',
preset_name varchar(50) NOT NULL DEFAULT '',
CONSTRAINT phpbb_presets_pkey PRIMARY KEY ( preset_id )
);
# mssql
CREATE TABLE [phpbb_presets] (
[preset_id] [bigint] IDENTITY (1,1) NOT NULL,
[preset_type] [varchar] (5),
[preset_name] [varchar] (50)
) ON [PRIMARY]
GO
ALTER TABLE [phpbb_presets] WITH NOCHECK ADD
CONSTRAINT [DF_phpbb_presets_preset_type] NOT NULL DEFAULT ('') FOR [preset_type],
CONSTRAINT [DF_phpbb_presets_preset_name] NOT NULL DEFAULT ('') FOR [preset_name],
CONSTRAINT [PK_phpbb_presets] PRIMARY KEY CLUSTERED ([preset_id]) ON [PRIMARY]
GO
Code: Select all
CREATE TABLE phpbb_presets (
preset_id SERIAL,
preset_type VARCHAR(5) NOT NULL DEFAULT '',
preset_name VARCHAR(50) NOT NULL DEFAULT '',
CONSTRAINT phpbb_presets_pk PRIMARY KEY (preset_id),
CHECK (preset_id>=0)
);
Code: Select all
CREATE TABLE phpbb_presets (
preset_id INTEGER NOT NULL IDENTITY(1, 1),
preset_type VARCHAR(5) NOT NULL DEFAULT (''),
preset_name VARCHAR(50) NOT NULL DEFAULT (''),
CONSTRAINT phpbb_presets_pk PRIMARY KEY (preset_id) ON [PRIMARY],
CHECK (preset_id>=0)
) ON [PRIMARY];