Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE employees(
- id INT AUTO_INCREMENT,
- name VARCHAR(40) NOT NULL,
- description VARCHAR(50) DEFAULT 'No Description',
- random_assignment_id INT UNIQUE,
- birth_date DATE,
- salary DECIMAL(5,2),
- supervisor_id INT,
- branch_id INT NOT NULL,
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT random_assignment_check CHECK (LENGTH(random_assignment_id) = 5),
- INDEX(random_assignment_id, supervisor_id, branch_id),
- PRIMARY KEY(id)
- )
- SHOW CREATE TABLE employeesG;
- *************************** 1. row ***************************
- Table: employees
- Create Table: CREATE TABLE `employees` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `name` varchar(40) NOT NULL,
- `description` varchar(50) DEFAULT 'No Description',
- `random_assignment_id` int(11) DEFAULT NULL,
- `birth_date` date DEFAULT NULL,
- `salary` decimal(5,2) DEFAULT NULL,
- `supervisor_id` int(11) DEFAULT NULL,
- `branch_id` int(11) NOT NULL,
- `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (`id`),
- UNIQUE KEY `random_assignment_id` (`random_assignment_id`),
- KEY `random_assignment_id_2` (`random_assignment_id`,`supervisor_id`,`branch_id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
- 1 row in set (0.01 sec)
- DESCRIBE employees;
- +----------------------+--------------+------+-----+-------------------+----------------+
- | Field | Type | Null | Key | Default | Extra |
- +----------------------+--------------+------+-----+-------------------+----------------+
- | id | int(11) | NO | PRI | NULL | auto_increment |
- | name | varchar(40) | NO | | NULL | |
- | description | varchar(50) | YES | | No Description | |
- | random_assignment_id | int(11) | YES | UNI | NULL | |
- | birth_date | date | YES | | NULL | |
- | salary | decimal(5,2) | YES | | NULL | |
- | supervisor_id | int(11) | YES | | NULL | |
- | branch_id | int(11) | NO | | NULL | |
- | created_at | timestamp | NO | | CURRENT_TIMESTAMP | |
- | updated_at | timestamp | NO | | CURRENT_TIMESTAMP | |
- +----------------------+--------------+------+-----+-------------------+----------------+
- brew info mariadb
- mariadb: stable 10.3.12 (bottled)
- Drop-in replacement for MySQL
Add Comment
Please, Sign In to add comment