Code icon

MYSQL - TYPES

Links


    //Types
    Id INT PRIMARY KEY,
    Fecha DATE default getdate(),
    FechaHora DATETIME default getdate(),
    Precio FLOAT not null,
    Dni CHAR(9) UNIQUE,
    Nombre VARCHAR(25) not null,
    Apellidos VARCHAR(30) not null,
    Municipio VARCHAR(40),
    Matricula VARCHAR(12) UNIQUE,
    Stock INT default 0 CHECK (Stock >= 0),
    Peso INT not null,
    PesoGr AS (Peso/100)


    // 
    You can create your own in the databases
    There might be differences in different databases

    identity (1,1) autonumerico empieza en 1 y va saltando de 1 en 1.  (1,2) Seria, 1,3,5...
    UNIQUE (no duplicable)
    constranint "PK DUplicada" (for restrictions like primary key or unique)