Thursday, April 1, 2010

Mysql Commands

Command to alter table engine:

ALTER TABLE my_table ENGINE = InnoDB;

Command to set foreign keys in Mysql, Oracle and Sql Server

MySQL:

ALTER TABLE ORDERS
ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID);

Oracle:
ALTER TABLE ORDERS
ADD (CONSTRAINT fk_orders1) FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID);

SQL Server:
ALTER TABLE ORDERS
ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID);

No comments:

Post a Comment