PL/SQL | T-SQL | Plage/exemple | C# |
tinyint | tinyint | 0 à 255 | byte (System.Byte) |
smallint | smallint | -32 768 à 32 767 | short(System.Int16) |
|
|
|
|
int | int | -2 147 483 648 à 2 147 483 647 | int(System.Int32) |
bigint | bigint | -9 223 372 036 854 775 808 à 9 223 372 036 854 775 807 | long(System.Int64) |
numeric(5,2) | numeric(5,2) | Exemple : 40,77 | float(System.Single) ou double/voir string |
decimal(5,2) | decimal(5,2) | Exemple : 40,77 | float(System.Single) ou double/voir string |
float,real | float |
| double (System.Double) |
bool | bit |
| bool(System.Boolean) |
char(50) | char(50) | de 1 à 4000 caractères | string(System.String) |
varchar(100) | varchar(100) | de 1 à 8000 caractères | string(System.String) |
national char(1000) | nchar(1000) | de 1 à 8000 caractères | string(System.String) |
text,longtext | text |
| string(System.String) |
date | date | Exemple : 2003-10-30 | DateTime(System.DateTime) |
time | Time(7) | Exemple : 13:00:00 | DateTime(System.DateTime) |
datetime | datetime | Exemple : 2003-10-30 13:00:00 | DateTime(System.DateTime) |
timestamp | timestamp |
| TimeSpan(System.TimeSpan) |
varbinary(100), blob | varbinary(100) | de 1 à 8000 | byte[](System.Byte[]) |
longblob | image |
| byte[](System.Byte[]) |
- types numériques, ne pas mettre d’espace
- Pour les types numeric, decimal, float mettre une virgule (et pas un point)
- decimal [ (p[ ,s] )] et numeric[ (p[ ,s]) -10^38 +1 et 10^38 - 1.
p (précision) Nombre maximal de chiffres décimaux à gauche et à droite de la virgule.Comprise entre 1 et 38(par défaut 18)
s (échelle) Nombre de chiffres décimaux à droite de la virgule. Ce nombre est soustrait de p. Comprise entre 0 et p (par défaut 0)
- Insérer une image dans une colonne en T-SQL :
INSERT INTO NOMTABLE(NOMCOLONNE) SELECT 'avatarcsharp.png' FROM OPENROWSET(BULK N'C:\Users\romagny\Pictures\avatarcsharp.png', SINGLE_BLOB) AS Document GO |
Exemple de table en T-SQL (SQL Server 2012)
create table DEMOTABLE ( DEMOOCTET tinyint null, DEMOSMALLINT smallint null, DEMOSEQUENCIEL int null, DEMOBIGINT bigint null, DEMONUMERIC numeric(5,2) null, DEMODECIMAL decimal(5,2) null, DEMOFLOAT float null, DEMOBOOL bit null, DEMOCHAR char(50) null, DEMOVARCHAR varchar(100) null, DEMOTEXT text null, DEMONATIONALCHAR nchar(1000) null, DEMODATE date null, DEMOTIME time(7) null, DEMODATETIME datetime null, DEMOHEURESYSTEME timestamp null, DEMOVBIN varbinary(1000) null, DEMOIMAGE image null ) |