Created
June 10, 2020 05:14
-
-
Save echo-akash/426e3a4eefa2270c563c62dc372f6745 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Add new column in database which is foreign key | |
ALTER TABLE database.table | |
ADD COLUMN columnname INT DEFAULT(1), | |
ADD FOREIGN KEY fk_name(fk_column) REFERENCES reftable(refcolumn) ON DELETE CASCADE; | |
--create table | |
CREATE TABLE IF NOT EXISTS checklists ( | |
todo_id INT AUTO_INCREMENT, | |
task_id INT, | |
todo VARCHAR(255) NOT NULL, | |
is_completed BOOLEAN NOT NULL DEFAULT FALSE, | |
PRIMARY KEY (todo_id , task_id), | |
FOREIGN KEY (task_id) | |
REFERENCES tasks (task_id) | |
ON UPDATE RESTRICT ON DELETE CASCADE | |
); | |
--change table column name | |
ALTER TABLE "table_name" Change "column 1" "column 2" ["Data Type"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment