Archive for September 21st, 2007

ALTER TABLE ORDERS FOREIGN KEY

MySQL:
CREATE TABLE ORDERS
(Order_ID integer,
Order_Date date,
Customer_SID integer,
Amount double,
Primary Key (Order_ID),
Foreign Key (Customer_SID) references CUSTOMER(SID));

Oracle:
CREATE TABLE ORDERS
(Order_ID integer primary key,
Order_Date date,
Customer_SID integer references CUSTOMER(SID),
Amount double);

SQL Server:
CREATE TABLE ORDERS
(Order_ID integer primary key,
Order_Date datetime,
Customer_SID integer references CUSTOMER(SID),
Amount double);

Below are examples for specifying a foreign key by altering a table. This assumes that the ORDERS table has been created, and the foreign key has not yet been put in:

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

MySQL migration: MyISAM to InnoDB

MySQL migration: MyISAM to InnoDB

 

By Keith Winston on July 18, 2005 (8:00:00 AM)

The MySQL database is unique in that it offers multiple storage engines. The SQL parser and front end interfaces are separate from the storage engines, so you can choose among nine low-level table formats the one that suits your application best. I recently needed to convert a production application from the default indexed sequential format, MyISAM, to InnoDB. Here’s my no-hassle guide to performing the conversion.

Read the rest of this entry »

No Comments

What is referential integrity?

 

Simply put, referential integrity means that when a record in a table refers to a corresponding record in another table, that corresponding record will exist. Look at the following:

Read the rest of this entry »

No Comments

terminal services

http://i-admin.blogspot.com/2005/06/how-to-crack-windows-terminal-services.html

No Comments

Backup – Restore SQL 2005

T-SQL code

BACKUP:

USE myDatabaseName

GO

BACKUP DATABASE myDatabaseName
TO DISK = ‘C:\filePath\myDatabaseName.bak’
NAME = ‘The name of the back up.’

 

RESTORE:

RESTORE databaseName

FROM DISK = ‘C:\filePath\backupFilename’

No Comments