How to set default values when creating a student table in MySQL?
You can use the DEFAULT keyword to set default values. When creating a student table, you can use the DEFAULT keyword in column definitions to set default values. For example, here is an example of creating a student table named students:
CREATE TABLE students (
student_id INT PRIMARY KEY,
student_name VARCHAR(50) NOT NULL,
registration_date DATE DEFAULT CURRENT_DATE
);
In the example above, the registration_date column is set as a DATE type, and the DEFAULT CURRENT_DATE is used to set the default value to the current date. This means that when inserting a new row, if a value for registration_date is not explicitly provided, the current date will be automatically used as the default value.