Set default value when creating a table in SQL

1

I am studying SQL Language and am having some problems in creating tables, I can not set a default value in a column, whenever I apply it indicates a syntax error. Can someone help me? I have no idea what is happening ... (If there are more errors and you can indicate, please, thank)

CREATE TABLE USUARIO
(

ID NUMERIC IDENTITY,

LOGIN VARCHAR(25) UNIQUE NOT NULL,

SENHA VARCHAR(15) NOT NULL,

DTEXPIRACAO DATE NOT NULL,

CONSTRAINT DF_DTEXPIRACAO DEFAULT(1900/01/01) FOR DTEXPIRACAO,

CONSTRAINT PK_USUARIO PRIMARY KEY (ID)

);
    
asked by anonymous 01.09.2018 / 00:38

2 answers

0
CREATE TABLE USUARIO
(
ID NUMERIC IDENTITY,
LOGIN VARCHAR(25) UNIQUE NOT NULL,
SENHA VARCHAR(15) NOT NULL,
DTEXPIRACAO DATE NOT NULL default '19000101',
CONSTRAINT PK_USUARIO PRIMARY KEY (ID)
);
    
02.09.2018 / 01:55
2

There were only a few details left in your query, after some adjustments it would look like this:

CREATE TABLE TESTE
(
    ID NUMERIC IDENTITY CONSTRAINT PK_USUARIO PRIMARY KEY (ID),
    LOGIN VARCHAR(25) UNIQUE NOT NULL,
    SENHA VARCHAR(15) NOT NULL,
    DTEXPIRACAO DATE NOT NULL CONSTRAINT DF_DTEXPIRACAO DEFAULT('1900-01-01')
);
    
01.09.2018 / 00:53