Basics of sql - preCharge Forums
It shows that you are unregistered. Please register with us by clicking Here
preCharge Forums


Nav Green LeftNav Right
preCharge Forums > Website Design & Development > Programming » Basics of sql


Reply
Tcat Right
 
LinkBack Thread Tools Display Modes Tcat Right
Old 07-26-2006   #1 (permalink)
alan86
Junior Member
 
alan86's Avatar
 
Join Date: Jul 2006
Age: 23
Posts: 10
Send a message via ICQ to alan86 Send a message via MSN to alan86
Default Basics of sql

Table creation

Code:
CREATE TABLE table_name (name type [, name type [, ...]]);
SQL standard types are:


CHARACTER(n)String size n
n from 1 up to 15000



DATEDate in mm/gg/aa format



TIMEHour in hh:mm format



INTEGER(p)Integer number with p precision
p from 1 up to 45
p da 1 a 45


SMALLINTInteger number with precision 5
from -32768 up to 32767



INTEGERInteger number with precision 10
from -2.147.483.648 up to 2.147.483.647



DECIMAL(p,s)Decimal number with precision p and s cifre
p from 1 up to 45 and s from 0 up to p



REALReal number Numero reale con mantissa di precisione 7valore 0 oppure valore assoluto da 1E-38 a 1E+38


FLOATNumero reale con mantissa di precisione 15valore 0 oppure valore assoluto da 1E-38 a 1E+38


FLOAT(p)Numero reale con mantissa di precisione pp da 1 a 45



For example, to create a table with the data of dependents of a company we have to use this command:
Code:
CREATE TABLE tblDependents(
   Id     char(5),
   Surname   char(30),
   Name    char(20),
   FiscalCode char(16) not null,
   Engaged   date,
   Branch   smallint,
   Function  char(15),
   Level    smallint,
   Salary   integer,
   Address   char(25),
   Cap     char(5),
   City    char(20),
   );

Data manipulation

To insert a new row we use INSERT command:
Code:
INSERT INTO table_name(name) VALUES(value);
To modify one or more rows we use UPDATE command:
Code:
UPDATE table_name SET name = value [, name = value [, ...]] WHERE name = value [, name = value [, ...]]
To delete one ore more rows we use DELETE command:
Code:
DELETE FROM table_name WHERE name = value [, name = value [, ...]]
In our example we will have:
Code:
INSERT INTO tblDependents
(Id, Surname, Name, FiscalCode, Engaged, Branch, Function, Level, 
  Salary, Address, Cap, City)
VALUES ('AB541', 'Rossi', 'Paolo', 'RSSPLA65M20R341E', '09/15/1997', 3, 'Impiegato', 5, 
  890, 'via roma 34', '20100', 'Milano');
If we want to modify the level of dependent having id AA345:
Code:
UPDATE tblPersonale
  SET Livello = 6
  WHERE Id = 'AA345';
To delete dependend having id AQ123:
Code:
DELETE FROM tblPersonale
  WHERE Id = 'AQ123';
SELECT command

The general structure is the following:
Code:
SELECT name [, name [, ...]]
  FROM table_name [, table_name [, ...]]
  WHERE name = value
   [AND name = value]
For example, we can have the list with surname, name and fiscal code of all dependents with Impiegato function in this way:
Code:
SELECT Surname, Name, FiscalCode
  FROM tblDependent
  WHERE Function = 'Impiegato';
If we want all data of those who live in Milan:
Code:
SELECT *
  FROM tblDependent
  WHERE City = 'Milano'

If you'd like to have more information, you can visit [http://www.alangiacomin.net/forum/index.php?board=21.0]here[/url]
alan86 is offline   Reply With Quote


Old 07-28-2006   #2 (permalink)
watchwood
Junior Member
 
Join Date: Jul 2006
Age: 22
Posts: 17
Send a message via MSN to watchwood
Default Re: Bases of sql

A useful reference, but I assume that by "Bases" you mean "Basics"?
__________________
watchwood
AoKH | Neversummer
watchwood is offline   Reply With Quote

Old 07-29-2006   #3 (permalink)
alan86
Junior Member
 
alan86's Avatar
 
Join Date: Jul 2006
Age: 23
Posts: 10
Send a message via ICQ to alan86 Send a message via MSN to alan86
Default Re: Basics of sql

Quote:
Originally Posted by watchwood
A useful reference, but I assume that by "Bases" you mean "Basics"?
yes, you are right.
alan86 is offline   Reply With Quote

Old 09-01-2008   #4 (permalink)
willyoumind
Senior Member
 
willyoumind's Avatar
 
Join Date: Jul 2008
Posts: 300
Default Re: Basics of sql

I didn't understand one thing here...

Why the "Milan" transformed into "Milano" inside the code? Is it a sligthly different between of the words and code?
willyoumind is offline   Reply With Quote

Old 05-12-2010   #5 (permalink)
Digit441
Junior Member
 
Join Date: May 2010
Posts: 19
Default Re: Basics of sql

In the "Milan" example you're searching for the partial keyword of "Milan" therefore any word containing that will show up including Milano, Milana etc. I believe it is case sensitive as well from what I remember so "milan" won't be the same as "Milan" and spacing definitely matters.
Digit441 is offline   Reply With Quote

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Got the Search Engine Optimization basics covered, what's next? alexa Search Engine Optimization 1 07-12-2006 06:26 AM
Php Basics Gaia Graphics & Multimedia 12 12-29-2005 08:01 PM
The Basics Of Brush Making Sanjiun Graphics & Multimedia 1 08-18-2005 05:32 AM


footer left
All times are GMT. The time now is 11:33 PM.

DISCLAIMER: preCharge Risk Management is not responsible for any opinions, advice or comments expressed on the preCharge Community Forums.
preCharge® is a registered trademark of preCharge Risk Management | chargeback protection | Merchant Account Blog

Powered by vBulletin
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0 RC6

Cheap Home Insurance | Canon 500d | Debt Help | Cheap Home Insurance | Project Management Software

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49