SQL Notes

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
CREATE TABLE `clients` (
  `id` int(4) NOT NULL AUTO_INCREMENT,
  `name` varchar(11) NOT NULL,
  `associate` varchar(100) NOT NULL,
  `revenue` int(12) NOT NULL,
  `profit` int(12) NOT NULL,
   PRIMARY KEY (`id`),
   FOREIGN key (`associate`) references `emp`(`emp_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
alter table `emp` add COLUMN `phone` int(12) not null after `name`
alter table `emp` add COLUMN `phone` int(12) null after `name`
alter table `emp` modify `phone` int(12) null
alter table `emp` drop column `phone`
 
 
ALTER TABLE `emp`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `emp_code` (`emp_code`);
 
--
-- AUTO_INCREMENT for dumped tables
--
 
--
-- AUTO_INCREMENT for table `emp`
--
ALTER TABLE `emp`
  MODIFY `id` int(4) NOT NULL AUTO_INCREMENT;
COMMIT;

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *