VPS business hosting starting at $29.95/24/7 premium technical support

SQL Notes

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;

Author: Harshvardhan Malpani

PHP Developer based in New Delhi, India. Working as a freelance web developer providing server deployment, website development and maintenance services.

Leave a Reply

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