Insert Into Pupil (Id, Name, DateBirth) Values (1, 'Charly', '19.01.2004'), (2, 'Sandy', '14.05.2004'), (3, 'Jim', '01.12.2003');
(3 row(s) affected)
Insert Into Pupil (Id, Name, DateBirth) Values (1, 'Charly', '19.01.2004'), (2, 'Sandy', '14.05.2004'), (3, 'Jim', '01.12.2003');
(3 row(s) affected)
You can imagine a TABLE in SQL as an Excel spreadsheet. It contains rows and columns with data in their fields.
Let us create a table for pupils. The table should contain information about the pupils unique Id, the Name and the Date of Birth.
The query for such a table will look like this:
CREATE TABLE Pupil ( Id int NOT NULL, Name varchar(50) NULL, DateBirth datetime NULL );
The Query starts with the command “Create Table [Tablename] (” followed by “Fieldname Datatype Nullable“. A Fieldname should be self explanatory. Available Datatypes see chapter below. Nullable means, if the value must be set. A fields default value is null (kind of empty or let’s undefined).
Here is a list of commonly used Datatypes
For further information about SQL Server and available Datatypes see http://technet.microsoft.com/en-us/library/ms187752.aspx.
Introduction << — >> Part 2
Understand the creation and modification of tables, how to handle data, do calculations and gain query speed.
Usually you will hear at this point a lot of theory. Terms like “Database normalization”, abstraction, tuples, redundancy and so on. My point of view – forget about it – first let’s see, what a database is and can do for you! Learning by doing.
Once you got the point, you can go further into details and optimizations.
Ok, here are a few terms you should have heard of you start.
Database
Database Management System
Table
Record
Field
Value
Datatype
SQL
DDL
DML
DCL
Query
Database Tool
>> Part 1
Login