New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change default IDENTITY to 1,1 #23656
Comments
Thank you for request |
I'm unable to reproduce your issue. Could you clarify, how do you create the table to get this behavior? |
Also which DBeaver version do you use? |
In SQL Server, when creating an identity column, set the default identity seed to 1 instead of 0. Per [Microsoft SQL Server documentation](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property?view=sql-server-ver16#increment), when creating an identity column, "You must specify both the seed and increment or neither. If neither is specified, the default is (1,1)." # Before fix ``` CREATE TABLE DatabaseName.dbo.NewTable ( Id int IDENTITY(0,1) NOT NULL, CONSTRAINT NewTable_PK PRIMARY KEY (Id) ); ``` # After fix ``` CREATE TABLE DatabaseName.dbo.NewTable ( Id int IDENTITY(1,1) NOT NULL, CONSTRAINT NewTable_PK PRIMARY KEY (Id) ); ```
I am not the original submitter of this issue, but I encountered this today in DBeaver Community Version 24.0.4.202405051837 In SQL Server, when you create a new identity column for a table and then click "Save", the resulting DDL defaults to an identity seed value of 0, which means the first record inserted into the table gets an id of 0. @E1izabeth Would you be open to me submitting a PR to fix this? |
@Sgierek106 we're open for contributions, sure. Here is some useful information on this matter https://github.com/dbeaver/dbeaver/wiki/Contribute-your-code |
In SQL Server, when creating an identity column, set the default identity seed to 1 instead of 0. Per [Microsoft SQL Server documentation](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property?view=sql-server-ver16#increment), when creating an identity column, "You must specify both the seed and increment or neither. If neither is specified, the default is (1,1)." # Before fix ``` CREATE TABLE DatabaseName.dbo.NewTable ( Id int IDENTITY(0,1) NOT NULL, CONSTRAINT NewTable_PK PRIMARY KEY (Id) ); ``` # After fix ``` CREATE TABLE DatabaseName.dbo.NewTable ( Id int IDENTITY(1,1) NOT NULL, CONSTRAINT NewTable_PK PRIMARY KEY (Id) ); ``` Co-authored-by: MashaKorax <84867187+MashaKorax@users.noreply.github.com>
Hello,
Currently, the default IDENTITY is (0,1):
However, could you please change it to (1,1) as it has MS SQL Server Management Studio by default?
Thanks.
The text was updated successfully, but these errors were encountered: