xxxxxxxxxx
CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
City varchar(255) DEFAULT 'Sandnes'
);
xxxxxxxxxx
/*Alter an existing column to add a default constraint*/
ALTER TABLE (Table_Name)
ADD CONSTRAINT (Constraint_Name)
DEFAULT (Default_Value) FOR (Existing_Column_Name)
xxxxxxxxxx
ALTER TABLE table_name
ALTER COLUMN column_name SET DEFAULT default_value;
xxxxxxxxxx
/*Adding a New Column, with default value to an existing table*/
ALTER TABLE (Table_Name)
ADD (Column_Name)(Data_Type) (Null/NOT NULL)
CONSTRAINT (Constraint_Name) DEFAULT (Default_Value)
xxxxxxxxxx
Sets a default value for a column;
Example 1 (MySQL): Creates a new table called Products which has a
name column with a default value of ‘Placeholder Name’ and an available_
from column with a default value of today’s date.
CREATE TABLE products (
id int,
name varchar(255) DEFAULT 'Placeholder Name',
available_from date DEFAULT GETDATE()
);
Example 2 (MySQL): The same as above, but editing an existing table.
ALTER TABLE products
ALTER name SET DEFAULT 'Placeholder Name',
ALTER available_from SET DEFAULT GETDATE();
xxxxxxxxxx
Are SQL attributes that have their default values even if the values are not provided
xxxxxxxxxx
const box = document.querySelector('.box');
let animationComplete = true;
box.addEventListener('mouseenter', () => {
if (animationComplete) {
animationComplete = false;
// Move the box to the right
gsap.to(box, {
x: 500, // Move box 500px to the right
duration: 2, // Duration of 2 seconds
onComplete: () => {
// Instantly return to the original position
gsap.to(box, {
x: 0, // Move box back to the original position
duration: 0, // No delay for the return (instant move)
onComplete: () => {
animationComplete = true; // Allow next hover to trigger the animation
},
});
},
});
}
});
xxxxxxxxxx
# For the most recent version of SQL:
ALTER TABLE table_name MODIFY column_name DATATYPE;
# Example:
ALTER TABLE payments MODIFY COLUMN currency VARCHAR(10);