Create table with getdate() function

Viewed 15939

Trying to create table that have a getdate() function

CREATE TABLE Orders 
(OrderId int NOT NULL PRIMARY KEY, 
 ProductName varchar(50) NOT NULL, 
 OrderDate datetime NOT NULL DEFAULT GETDATE() 
);

but got an error

ora-00901 right parenthesis missing

3 Answers

Since we do not need to write NOT NULL as it accepts default function.

You can try this:

CREATE TABLE Orders 
(OrderId int NOT NULL PRIMARY KEY, 
 ProductName varchar(50) NOT NULL, 
 OrderDate datetime DEFAULT GETDATE() 
);
Related