forked from miguelgfierro/codebase
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmanage_table.sql
More file actions
30 lines (23 loc) · 769 Bytes
/
Copy pathmanage_table.sql
File metadata and controls
30 lines (23 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- Cheatsheet: https://github.com/FavioVazquez/ds-cheatsheets/blob/master/SQL/SQL-cheat-sheet.pdf
-- Drop the table if it exists
IF OBJECT_ID('table_name') IS NOT NULL
DROP TABLE table_name;
-- Create a table with different variables. Not null variables must be always be filled, the rest
-- may have null values
CREATE TABLE table_name
(
patient_id varchar(50) NOT NULL PRIMARY KEY,
size_row INT NOT NULL,
size_col INT DEFAULT 0,
array varbinary(max)
);
-- Add a new column to the table
ALTER TABLE t ADD column;
-- Drop column c from the table
ALTER TABLE t DROP COLUMN c;
-- Rename a table from t1 to t2
ALTER TABLE t1 RENAME TO t2;
-- Rename column c1 to c2
ALTER TABLE t1 RENAME c1 TO c2;
--Remove all data in a table
TRUNCATE TABLE t;