Tuesday, June 21, 2011

MSSQL SERVER vs MYSQL

MSSQL SERVER

CREATE TABLE [dbo].[table1](
    [id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
    [name] [nvarchar](10) primary key NOT NULL,
    [col] [nvarchar](20) NOT NULL
)

exec sp_RENAME 'table1.col', 'age', 'COLUMN'

ALTER TABLE tableName
ALTER COLUMN age int NOT NULL


MYSQL SERVER

mysql> create table table1(
    -> id int(10) unsigned primary key auto_increment,
    -> name varchar(100) not null,
    -> col smallint);
Query OK, 0 rows affected (0.38 sec)

mysql> alter table table1
    -> change column col age int;
Query OK, 0 rows affected (0.21 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc table1;
+-------+------------------+------+-----+---------+----------------+
| Field | Type             | Null | Key | Default | Extra          |
+-------+------------------+------+-----+---------+----------------+
| id    | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| name  | varchar(100)     | NO   |     | NULL    |                |
| age   | int(11)          | YES  |     | NULL    |                |
+-------+------------------+------+-----+---------+----------------+
3 rows in set (0.13 sec)

No comments: