default in mysql code example

Example 1: how to add default constraint in mysql

ALTER TABLE "name_table" ALTER "name_column" 
SET DEFAULT value_default;

Example 2: set default value mysql db

ALTER TABLE mytbl ALTER j SET DEFAULT 1000;

Example 3: mysql default value

CREATE TABLE table_name(
   column_name data_type,
   Column_name data_type DEFAULTvalue);

Example 4: provide hardcoded value in the mysql query

SELECT "" as Serial,
   "" as Object_ID,
   "" as ObjectDEsc,
   "" as Object_Num,
   "--(UNKNOWN -- )" as DropList
UNION
 SELECT CAST(p.Serial AS UNSIGNED INTEGER) as Serial, 
  p.Object_ID, 
  p.Part_ID, 
  st.Description AS ObjectDesc, 
  s.Object_Num, 
  concat(Serial,' (',st.Desc,' #',s.Object_Num,')') as DropList 
 FROM Parts p LEFT JOIN Objects s ON p.Object_ID = s.Object_ID 
 LEFT JOIN ObjectTypes st ON s.ObjectType_ID = st.ObjectType_ID

Tags:

Sql Example