Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

alter-table

Alter a MySQL column to be AUTO_INCREMENT

October 10, 2022 by Tarik

ALTER TABLE document MODIFY COLUMN document_id INT auto_increment

Categories sql Tags alter-table, mysql, sql Leave a comment

SQL Server add auto increment primary key to existing table

September 29, 2022 by Tarik

No – you have to do it the other way around: add it right from the get go as INT IDENTITY – it will be filled with identity values when you do this: ALTER TABLE dbo.YourTable ADD ID INT IDENTITY and then you can make it the primary key: ALTER TABLE dbo.YourTable ADD CONSTRAINT PK_YourTable … Read more

Categories sql-server Tags alter-table, primary-key, sql-server, sql-server-2008 Leave a comment

How can I add a column that doesn’t allow nulls in a Postgresql database?

September 29, 2022 by Tarik

You have to set a default value. ALTER TABLE mytable ADD COLUMN mycolumn character varying(50) NOT NULL DEFAULT ‘foo’; … some work (set real values as you want)… ALTER TABLE mytable ALTER COLUMN mycolumn DROP DEFAULT;

Categories sql Tags alter-table, postgresql, sql Leave a comment

How can I modify the size of column in a MySQL table?

September 29, 2022 by Tarik

Have you tried this? ALTER TABLE <table_name> MODIFY <col_name> VARCHAR(65353); This will change the col_name‘s type to VARCHAR(65353)

Categories mysql Tags alter-table, database, mysql Leave a comment

How do I rename a column in a SQLite database table?

September 28, 2022 by Tarik

Note that as of version 3.25.0 released September 2018 you can now use ALTER TABLE to rename a column. Original “create new and drop old table” answer below. Say you have a table and need to rename “colb” to “col_b”: First create the new table with a temporary name, based on the old table definition … Read more

Categories sqlite Tags alter-table, sqlite Leave a comment

Altering column size in SQL Server

September 25, 2022 by Tarik

ALTER TABLE [Employee] ALTER COLUMN [Salary] NUMERIC(22,5) NOT NULL

Categories sql Tags alter-table, database, sql, sql-server, tsql Leave a comment

How do you change the datatype of a column in SQL Server?

September 22, 2022 by Tarik

ALTER TABLE TableName ALTER COLUMN ColumnName NVARCHAR(200) [NULL | NOT NULL] EDIT As noted NULL/NOT NULL should have been specified, see Rob’s answer as well.

Categories sql-server Tags alter-table, sql-server, tsql, type-conversion Leave a comment

How to rename a table in SQL Server?

September 18, 2022 by Tarik

To rename a table in SQL Server, use the sp_rename command: exec sp_rename ‘schema.old_table_name’, ‘new_table_name’

Categories sql-server Tags alter-table, rename, sql-server Leave a comment

Error renaming a column in MySQL

September 17, 2022 by Tarik

Lone Ranger is very close… in fact, you also need to specify the datatype of the renamed column. For example: ALTER TABLE `xyz` CHANGE `manufacurerid` `manufacturerid` INT; Remember : Replace INT with whatever your column data type is (REQUIRED) Tilde/ Backtick (`) is optional

Categories mysql Tags alter-table, database, mysql, mysql-error-1025 Leave a comment

Adding multiple columns AFTER a specific column in MySQL

September 16, 2022 by Tarik

Try this ALTER TABLE users ADD COLUMN `count` SMALLINT(6) NOT NULL AFTER `lastname`, ADD COLUMN `log` VARCHAR(12) NOT NULL AFTER `count`, ADD COLUMN `status` INT(10) UNSIGNED NOT NULL AFTER `log`; check the syntax

Categories mysql Tags alter-table, ddl, mysql Leave a comment
Older posts
Newer posts
← Previous Page1 … Page5 Page6 Page7 Next →

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa