Search
 
SCRIPT & CODE EXAMPLE
 

SQL

alter table add column and foreign key mysql

ALTER TABLE database.table
  ADD COLUMN columnname INT DEFAULT(1),
  ADD FOREIGN KEY fk_name(fk_column) REFERENCES reftable(refcolumn) ON DELETE CASCADE;
Comment

alter table add column forigen key mysql

ALTER TABLE tryholpz_demo07.core_modules 
ADD COLUMN belongs_to_role INT, 
ADD FOREIGN KEY core_modules(belongs_to_role) REFERENCES role_specific_modules_info(id) ON DELETE CASCADE
Comment

mysql alter table add column first

-- ALTER TABLE tbl_name ADD COLUMN column_name column_definition 
--		[FIRST|AFTER existing_column];
ALTER TABLE office ADD COLUMN phone VARCHAR(200) DEFAULT '000' AFTER name;
ALTER TABLE office ADD COLUMN flag INT(1) FIRST;
ALTER TABLE office ADD COLUMN last_col INT(2);	-- Last column is default position
-- ↓ Test it (Fiddle)
Comment

add column mysql with foreign key

ALTER TABLE `TABLE_NAME`
ADD COLUMN `COLUMN_NAME` BIGINT(20) UNSIGNED NULL DEFAULT NULL AFTER `AFTER_COLUMN_NAME`, 
ADD FOREIGN KEY `FOREIGN_RELATION_NAME`(`COLUMN_NAME`) REFERENCES `FOREIGN_TABLE`(`FOREIGN_COLUMN`)  ON UPDATE SET NULL ON DELETE SET NULL
Comment

PREVIOUS NEXT
Code Example
Sql :: SQL rounding numbers 
Sql :: Get Minimum from multiple columns sql 
Sql :: get date ISO in psql 
Sql :: restore postgres database from dump 
Sql :: mysql add to number 
Sql :: postgresql create schema in specific database 
Sql :: mysql select where starts with 
Sql :: rename constraint postgresql 
Sql :: locate sql server 
Sql :: sql view where tables have same column name combine results 
Sql :: sql add column to table 
Sql :: how to get duplicate records with multiple field in sql 
Sql :: change role postgres 
Sql :: mysqli last row 
Sql :: csv to sqlite python 
Sql :: copy table postgres 
Sql :: Assign value to var in SQL 
Sql :: sql drop default 
Sql :: mysql update column default value CURRENT_TIMESTAMP error 
Sql :: sql mm/dd/yyyy format 
Sql :: oracle list columns in schema 
Sql :: sql select into 
Sql :: mysql command not working in linux 
Sql :: sql blank vs null 
Sql :: mysql store ip address 
Sql :: postgresql resolv duplicate value violates unique constraint 
Sql :: get first monday of month sql 
Sql :: update and replace mysql 
Sql :: SQL NOT BETWEEN Operator 
Sql :: ascending order and where in sql 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =