About 273,000 results
Open links in new tab
  1. How to add a column with a default value to an existing table in …

    Sep 18, 2008 · This is for SQL Server: ALTER TABLE TableName ADD ColumnName (type) -- NULL OR NOT NULL DEFAULT (default value) WITH VALUES Example: ALTER TABLE …

  2. Adding a column after another column within SQL

    Nov 3, 2010 · It depends on what database you are using. In MySQL, you would use the "ALTER TABLE" syntax. I don't remember exactly how, but it would go something like this if you …

  3. sql server - Altering a column: null to not null - Stack Overflow

    Mar 27, 2009 · ALTER TABLE table_name CHANGE COLUMN column_name column_name VARCHAR(200) NOT NULL DEFAULT ''; Change VARCHAR(200) to your datatype, and …

  4. sql - How to add a sequence column to an existing table with …

    ALTER TABLE userlog ADD( user_id number ); create a sequence. CREATE SEQUENCE user_id_seq START WITH 1 INCREMENT BY 1 CACHE 20; Update the data in the table. …

  5. sql server - SQL-script: How to write ALTER statements to set …

    @ChristopheHarris, sometimes it makes sense to have more than one column as the primary key. A one-to-many or many-to-many relationship table will likely have 2 or more foreign key …

  6. How to change column order in a table using sql query in sql …

    Oct 22, 2009 · ALTER TABLE tablename DROP COLUMN columnname; ALTER TABLE tablename ADD columnname columntype; Note: only do this if you don't have data in the …

  7. sql - ALTER TABLE WHERE Clause - Stack Overflow

    Oct 13, 2014 · This is why there is no WHERE clause for ALTER. It sounds like you are looking to drop this column only if all of the values are NULL in the table. What you need is an IF …

  8. How do I rename a column in a database table using SQL?

    Oct 6, 2008 · In MySQL, the syntax is ALTER TABLE ... CHANGE: ALTER TABLE <table_name> CHANGE <column_name> <new_column_name> <data_type> ... Note that you can't just …

  9. sql server - Add a column to a table, if it does not already exist ...

    Jan 15, 2012 · IF COLUMNPROPERTY(OBJECT_ID('dbo.Person'), 'ColumnName', 'ColumnId') IS NULL BEGIN ALTER TABLE Person ADD ColumnName VARCHAR(MAX) NOT NULL …

  10. SQL Server add auto increment primary key to existing table

    Jul 14, 2017 · 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 PRIMARY …

Refresh