Tipologio Pli10-11

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

29  210.38.22.

157 495
www.arnos.gr e-mail : info@arnos.gr

10

fast & easy

1.

.


, bit. , - Hamming.
-
,
. - :
:
n
n -1
0
. SCII (American Standard Code for
Information Interchange)
7 bits
27 = 128 .
94 (, ,
) 34
.. BS (backspace)
.
7
: 011
, 8
011 1000.
. E O
T
8 bits
ASCII bit 0, 1 .
C
00100011.
. Unicode
. .
16 bits 65536 .
:
unicode 216 = 65536 .
2.
. (Parity Checking)



.
n bits bit


. ,

010011

0100111,

0100110.

A = (a n a n 1...a 0 ) = a n + n -1

+ ... + a 0

: .
(Binary)

0 1
2, :
(b n ...b1b0 ) 2 = (b n 2 n + ... + b1 21 + b 0 20 )10

.. 0101 =
= 1 20 + 0 21 + 1 22 + 0 23 =
= 1 1 + 0 2 + 1 4 + 0 8 =
= 1+4= 5
1 bit,
8 bits 1 byte.
1 byte 28 = 256 .
2 bytes
216 = 65536 . n bits 2n -1 (
), -2n-1+1
2n-1-1 2n ( )
0 2n-1. n=15,
32767 32767
2 bytes.
(Octal)
8.

0 7.
.. 15 = 17
3 bits
( 23 = 8).
bytes (.. ASCII).
(Hexadecimal)
(hexadecimal
hex)
16.
: 0 1 2 3 4 5 6 7 8 9 A B C D E F.
= 10, = 11, C = 12, D = 13, E = 14, F = 15
.. 15 = F ()
4
bits (24 = 16).
To
.





.: 210.38.22.157 210.38.22.495

www.arnos.gr

0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
10000

00
01
02
03
04
05
06
07
10
11
12
13
14
15
16
17
20

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

0
1
2
3
4
5
6
7
8
9

C
D
E
F
10

.


A10 = (a n a n 1...a 0 ) = a n n + ... + a 00

: .
.. 111110 = 0 20 + 1 21 + 1 22 + 1 23 +
1 2 4 + 1 2 5 = 0 + 2 + 4 + 8 + 16 + 32 = 62

2.
62 : 2
31 : 2
0
15 : 2
1

7:2
1

3:2
1
1:2
1
0:2
1

, 111110.
.


8.

(1001)2

3
2
1
0
= 1 2 + 0 2 + 0 2 + 1 2 = 910

9: 8
1: 8
1
0: 8
1
(11)8


.
3 bits
1 .

(76)8 = (111

110)2

.


16.
4 bits
1 .

(111110)2 = 6210
..
62 : 16
3 : 16 14 
0 : 16
3  3
6210 = (3)16
 4 bits
(F3)16 = (F 3)16 = (1111 0011)2
-

F=xy

F=xy

,
,
.
F 3
,
NAND
F=(xyz).

:
.
(Arithmetic and Logic Unit ALU)
E .
. (Control Unit)


.

. (Central Memory)

.
. M M (Mass Memory)

.
. (nput Units)
.
. (Output Units)
.



.
(address)
. , ,
.

ALU (processor) .

(HARDWARE)
(Central

Processing Unit, CPU).
.



O


:

(Magnetic disks)
. (Optical disks)
(floppy disks)
(software). To (Magnetic tapes) .
 (system software)
To
.



: (operating system) .
, ,


(compilers)
, telex,



(sensors)




.
:  (applications

software)



(applications package),
, ,



, Telex
,
.


:
.

.
Minicomputers
.
Microcomputers .
(work stations)

.
(special
purpose computer) .

29  210.38.22.157 495
www.arnos.gr e-mail : info@arnos.gr

fast & easy

10

()
() .
ANSI
:

("", EOL);

("---------------");
:
("A - ",EOL);

(" - ",EOL);
/ :
("E E",EOL);
..
(EOL);

(" :");
I,J,K: Integer;
(epilogi);
A : Real;
:=;
X : Char;
OK : Boolean;

A : ARRAY[0..9] OF Integer;

F : ARRAY[1..5,1..7] OF Real;

,, : Integer;
:= ;

:= ;
:= ;
:
( - ( )
)

..
();
();
(X);
- (NAME);
(,,);
. -

(- :
)
.
("", )

:
:
_

A := B / C;
A := A / 3;
A := A*B/C;

DIV

A:=B DIV 2;
A:=B DIV C;

MOD

A:=B MOD C;
A:=A MOD 3;

("", )

( )

( )
()

("", ) -

..........

()

()

Integer

Real
Char

Boolean

1,23,100
123.456
"A","0"
True (1),
False (0)

..

();
();
(X);
(NAME);
(,,,);
("[",,"]=",[]);

:=
;

{ } /* */

..

P=3.1415927;
M=32767;
ZRO=0;
EUR=340.75;

..

epilogi : CHAR;
, : INTEGER;

A:=
A:=
A:=
A:=
A:=
A:=

B-C;
A-1;
A-B-C;
B*C;
A*3;
A*B*C;

( )

A = B
:

A:= B+C;
A:= A+1;
A:= A+B+ C;

A
A
A
A

<> B
< B
<= B
> B
>=

, : BOOLEAN;
(AND)
H

AND B

(OR)

A OR B

OI (NOT)

NOT A

(AND):
H (OR) :
OI (NOT): ,

...

www.arnos.gr


A
T
T
F
F

B
T
F
T
F

A AND B

A OR B

NOT A

T
F
F
F

T
T
T
F

F
F
T
T

T:True, F: False


A AND B
,
.
A OR B
,
.


TEMP : INTEGER;
:
A
_1( )
TEMP:=A;

A:=B;

B:=TEMP;

_1 :

()

:INTEGER;
........
()

: INTEGER;
_;

_1 :=A*A;
.
: _;
INTEGER,
REAL,
CHAR

{ }
BOOLEAN.

NOT A
.
..

-

, ,
- ( ).
, :

.

.
(procedures)

..
.
(functions)

, .
:

_;

_1( )

_1: , ( ) :

.

(
).

, %
.

() .
........
()
..
_;

_1( )

_1 -
X, Y, _2 : INTEGER;
.
(%, %)
..
(%, %),

, : INTEGER;
,
,

, : INTEGER;
.

(" :");
();
(" :");
();
_2:= ();
(,);
("*=",_2);
(" :",);
(" :",);

{ }

(Structures Records)

, ..

Eggrafi :
field1 : INTEGER;
field2 : REAL;
field3 : ARRAY[1..20] OF CHAR;

Eggrafi
.
Eggrafi :

x, y : Eggrafi;

T
,

.
"." , ..
x.field1 := 1;
x.field2 := 10.0;
y.field1 := 2;
y.field2 := 20.0;






www.arnos.gr

29  210.38.22.157 495
www.arnos.gr e-mail : info@arnos.gr

10


1. EAN ( )

( ) . .
EAN {C} TOTE
{S1}
-

..
EAN A = 0 TOTE
("");
-

{S1}

EAN I >= 0 AND I <= 1000 TOTE


(" 0 1000");{S1}
-

fast & easy


(Loops)
() ()
2 1. 1, 0.
:
( MOD 2 = 0)
:=
(, " ")

... ( )
(, " ")
- .
-
 , 


-
()
.
. > 0
, ("");
{S1}
< 0
(""); {S2}

.
("");
-
-

{S3}

EAN I < 0 OR I > 1000 TOTE


(" 0
1000"); {S1}
-
,

EAN NOT I >= 0 TOTE


(" 0"); {S1}
-



{S1} 2.
{C} , - {S2}.
.

{C}
{S1}

{S2}
-

..
= 0
("");

(" TOY ");


-

!!!





();
()
(=1)
("");
(=2)
("");
(=3)
("");

("");
-

..
1
10
:= 1 10
();
-

{S1}
{S2}
{S3}
{S4}

2.


:

... ( )
{S1}
- .

.

.



.
,
,
-.


(). (
) 1 (

___
).

..
:= 1;
<= 10
();
{S1}
:= + 1;
-

I, COUNT : INTEGER;
A : REAL;
APH
COUNT:= 0;
I:=1 10
(" : ");
(A);
EAN A > 0.0 TOTE
COUNT := COUNT + 1;
EAN-
-
("IA : ",COUNT);

3.


:

... ( )
.

{S1}

I : INTEGER;
A,SUM,MO : REAL;
APXH
SUM:=0.0;
I:=1 10
("DOSTE ARITHMO : ");
(A);
SUM := SUM + A;
-
MO := SUM/10;
("MESOS OROS =",MO);


,
,

.


- .
() . ( ) __
{ =-10000.0 }
( -
A,SUM,M_O : REAL;
).
COUNT : INTEGER;

__

APXH
SUM:=0.0;
COUNT=0;
("DOSTE ARITHMO : ");
(A);
A <> -10000.0
APXH
COUNT := COUNT + 1;
SUM:=0.0;
SUM := SUM + A;
I:=1 10
("DOSTE ARITHMO : ");
("DOSTE ARITHMO : ");
(A);
(A);
-
SUM := SUM + A;
EAN COUNT=0 TOTE
-
M_O:=0;
("A8ROISMA =",SUM);

_:= SUM/COUNT;
-

("MESOS OROS=",_);

-

.
I : INTEGER;
A,SUM : REAL;
.

..
:=0;

:= + 1;
();
= 10;

{S1}

. 1

.

,
__
.

I : INTEGER;
A,PROD : REAL;

APXH
PROD:= 1.0;
I:=1 10
("DOSTE ARITHMO : ");
(A);
PROD := PROD * A;
-
("GINOMENO =",PROD);

__
{ ZHTEITAI POSO APO 1 OS 999 }

POSO : INTEGER

(" : ");
(POSO);
POSO >=1 KAI POSO <=999;
(" ");

29  210.38.22.157 495
www.arnos.gr e-mail : info@arnos.gr

10



. .
.

.

SUM:=0;
:= 0 9
(" [",,"]= ");
([]);
SUM := SUM + [];
-;

I,,, : INTEGER;

-

A : ARRAY[0..9] OF Integer;
I,SUM : Integer;


A[0] := 5;
A[1] := A[0] + 2;
[] := [] + 1;
EAN ( A[I] = 0 ) TOTE

-;


:= 0 9
([]);

-;

___

APXH
:=32767;
:=-32768;
I:=1 10
("DOSTE ARITHMO : ");
(A);
> := ;
< := ;
-
("O MEGALYTEROS ",);
("O MIKROTEROS ",);

fast & easy

()


()
(
) Bubble
Sort ( ).
1 (L).
.
.
,
DONE.

,
, .

BUBBLE_SORT

=9;

: ARRAY[0..N] OF INTEGER;

J,L,T : INTEGER;

DONE : BOOLEAN;
- -
.
L:= N;
,
DONE := TRUE;
, L:= L 1;
.
J:= 0 L
__
A[J] > A[J+1] TOTE

DONE := FALSE;
M = 10;
T := A[J];

A[J] := A[J+1];
P : ARRAY[1..M] OF INTEGER;
A[J+1] := T;
N,SUM,I : INTEGER;
-
MO : REAL;
-
APXH
DONE
(N); { <= }

I:= 1 N
(P[I]);
-
SUM:=0;
I:= 1 N
(P[I]);
SUM := SUM + P[I];
-
MO := SUM/N;
(MO);

:= 0 9
([]);
-;



(Linear Search)


,
.

.
.

N=10;

A : ARRAY[1..N] OF Integer;
I, TIMH : Integer;
FOUND : Boolean;

FOUND := FALSE;
();
I := 1;
(NOT FOUND) AND (I<=N)

A[I] = TIMH TOTE


FOUND := TRUE;

:= I + 1;
-
-
FOUND
("B ",A[I], "
",I, EOL);

(" ",EOL);
-

N=10;

A : ARRAY[1..N] OF Integer;
I, TIMH,TOP,MID,BOT : Integer;
FOUND : Boolean;

TOP:= 1;
BOT := N;
FOUND := FALSE;
();
(NOT FOUND) AND (TOP<=BOT)

MID := (TOP+BOT) / 2;
EAN A[MID] = TIMH TOTE
FOUND := TRUE;
A[MID] > TIMH TOTE
BOT := MID-1;

TOP := MID+1;
-
-
FOUND
("B ",A[I], "
",I, EOL);

(" ",EOL);
-


I, J
.


2 1
I:=1
F[,2]:= F[,2]+1;
-


3 = 1 + 2

J:=1 M
F[3,J]:= F[1,J]+F[2,J];
-


I:=1
J:=1 M
(F[I,J]);
-
(EOL);
-

(Binary Search)


,
.
.

, ,

. ,
. .

www.arnos.gr

( )

=3;
M=10;

F: ARRAY[1..N,1..M] OF Real;
I,J : Integer;




I = J.

I+J = +1 (
ARRAY[1..N,1..M]) I+J =
(

ARRAY[0..N,0..M]).
_

=3;

A: ARRAY[1..N,1..N] OF Real;
SUM1,SUM2 : Real;


( -
SUM1:=0.0;
)
I:=1
J:=1 M
F[I,J] := 0.0;
-
-

SUM2:=0.0;
I:=1
J:=1 M
I = J
SUM1 := SUM1+A[I,J];
-
(I + J) = (+1)
SUM2 := SUM2+A[I,J];

-
-
-

29  210.38.22.157 495
www.arnos.gr e-mail : info@arnos.gr

fast & easy

10 E



int , ;
C
:
:
(AND)
printf (" ",
H (OR)
#include <stdio.h>
)
#define
const

OI (NOT)

( )

int
char ( )
struct
int f1() {( )
.........
()
}
main() {
..........
}

()
()
()


;
/*


*/

int
short
long
float
double
char

-1,23,100


= ;
..
i = 1;
j = t = 3;
j = i + 3;
x = ;
a = 123.45;

int

"A","0"

t = a;
a = b;
b = t;

#define

const
= ;
..
#define ZRO 0
#define EUR 340.75
P=3.1415927;
M=32767;



:
/;
..
int i,j,k;
float a;
char x;
int
A[10];
float F[5][7];

a,b,t;

( )
+

++

--

! A


(Structures - Records)

, ..
struct Eggrafi {
int
field1;
float field2;
char field3[20];
};

Eggrafi
.
Eggrafi :
struct Eggrafi x, y;

123.456

const
const

..
printf("%d", i);
printf("%f", a);
printf("%c", x);
printf("%s", name);
printf("%d %s %d %f", i, name,
k,a );
printf("%f\n",a);

&& B
A || B

a = b+c;
a = a+b+c;
a += b+c;
a++; ++a;
a = b-c;
a = a-b-c;
a -= b-c;
a--; -a;
a = b * c;
a = a * b;
a *= b;
a = b / c;
a = a / b;
a /= b;
a = b / 2;
a = b / c;
a,b,c

a = b % c;
a = c % 3;
a = a % b;
a %= b;

scanf(" ", ( )
)

a == b
..
,
a != b
scanf("%d", &i);
scanf("%f", &a);

a < b
scanf("%c", &x);

a <= b
scanf("%s", name);

a > b
scanf("%d %d %f", &i, &k, &a);

a >= b


T
,

.
"."
..
x.field1
x.field2
y.field1
y.field2

=
=
=
=

1;
10.0;
2;
20.0;


1. if ( )
if /*S1*/ /*C*/
. .
if ()
;

/* C */
/* S1 */

if () {
/* C */
1; ... k; /* S1 */
}

..
if( a == 0 )
printf("");
if( i >= 0 && i <= 1000 )
printf(" 0 1000");
if( i < 0 || i > 1000 )
printf(" 0
1000");
if( ! (i >= 0) )
printf(" 0");

if else ( )
if - else {S1}
{C} , {S2}.
if ()
1;
else
2;

/* C */
/* S1 */
/* S2 */

if () {
/* C */
1; ... k; /* S1 */
}
else {
1; ... k; /* S2 */
}
..
if (a > b)
max = a;
else
max = b;
if (a >= 0){
a *= a;
printf("%d ", a);
}
else{
a += a
printf("%d ", a);
}

1 10.

for(a=1; a<=10; a++)
printf("%d",a);

, 10 1.

, for(a=10; a>=1; a--)
printf("%d",a);
n.
1
int n;
10.
printf(" EIO\n");
printf(" --------\n");
printf("1. \n");
printf("2. \n");
printf("3. E\n");
printf("\n");
printf(" 1, 2 3:");
scanf("%d",&n);
switch (n) {
case 1:
printf(" "); break;
case 2:
printf(" "); break;
case 3:
printf("E "); break;
default:
printf(" ");break;
}


(Loops)

for(a=1; a<=10; a+=2)


printf("%d",a);

2. while




:
while ( )
;

while ( ) {
1; 2; ... k;

}

.
.
..

1 10
1. for
a = 1;
() ()
while (a <= 10) {
2 for :
printf("%d",a);
{S1}
1, 0.
a++;
1. for( = ; <= ; =+ )
if (a % 2 == 0)
printf("%d : ZYGOS\n", a);
else
printf("%d : MONOS\n", a);

.
{ } .
if (a > 0)
printf("");
else if(a < 0)
printf("");
else
printf("");

for( = ; <= ; =+ ) {

3. do - while
1; 2; ... k;
}

2. for( = ; >= ; = + )
:
;
do

for( = ; >= ; =+ ) {

1; 2; ... k; while();

}
= , =
= , = .

1. (
>0)
()
. 2. switch
,


(__k) .
2. (
.
break <0)
switch, ()
. case.
,
switch () {

case __1: ; break;
case __2: ; break;
.
. . .
case __k: ; break;
..
default : ; break;
}

do {
1; 2; ... k;
}

while();
.


..
1 10
a = 0;
do {
a++;
printf("%d",a);
}
while (a<10);






!!

29  210.38.22.157 495
www.arnos.gr e-mail : info@arnos.gr

10 Z

fast & easy

C ()


(). (
) 1 (

).
..
/* 10 */
#include <stdio.h>
int i,count;
float a;
void main() {
count=0;
for (i=1;i<=10;i++) {
printf("DOSTE ARITHMO : ");
scanf("%f",&a);
if ( a > 0.0 )
count ++;
}
/* for */
printf("8ETIKA : %d",count);
}
/* main */


(). ( )

(
).
..
#include <stdio.h>
/* =10 */
int i;
float a,sum;
void main() {
sum=0.0;
for (i=1;i<=10;i++) {
printf("DOSTE ARITHMO : ");
scanf("%f",&a);
sum += a;
}
/* for */
printf("A8ROISMA = %f",sum);
}
/* main */


. 1

.
..
#include <stdio.h>
/* =10*/
int i;
float a,prod;
void main()
{
prod=1.0;
for (i=1;i<=10;i++) {
printf("DOSTE ARITHMO : ");
scanf("%f",&a);
prod *= a;
} /* for */
printf("GINOMENO = %f",prod);
}



.
,
,
for.
..
#include <stdio.h>
int i;
float a,sum,mo;
void main() {
sum=0.0;
for (i=1;i<=10;i++) {
printf("DOSTE ARITHMO : ");
scanf("%f",&a);
sum += a;
} /* for */
mo = sum/10;
printf("MESOS OROS = %f",mo);
}
/* main */

while ((poso<1) || (poso>999));


printf ("poso sosto");
}



. .
.

.
.. /* Eyresi megistoy-elaxistoy */
#include <stdio.h>
int min,max,a,i;

main() {
min=32767;
max=-32768;

for(i=1;i<10;i++){
,
printf("DOSE ARITHMO:");
scanf("%d",&a);
,
if(a>max)
while.
max=a;
.
if(a<min)
..
min=a;
#include <stdio.h>
}
printf("MEGALYTEROS=%d\n",max);
float a,sum,mo;
printf("MIKROTEROS=%d\n",min);
int count;

void main()
{
sum=0.0;
count=0;

/* -10000.0 */
printf ("dose arithmo:");
scanf ("%f",&a);
while (a!=-10000.0) {
count++;
sum+=a;
printf ("dose arithmo:");
scanf ("%f",&a);
}
if(count==0)
mo = 0.0;
else
mo = sum/count;
printf("mo = %f\n",mo);

}


,
do while.
..



[];
..
int a[10];


..
a[0] = 5;
a[1] = a[0] + 2;
if ( a[i] == 0 ) {


..
for ( i=0; i<=9; i++ )
scanf("%d", &a[i] );


..

sum=0;
for ( i=0; i<=9; i++ )
#include <stdio.h>
sum += a[i];
/* zhteitai poso apo 1 os 999 */
int poso;
main()
{
do {
printf("doste poso:");
scanf ("%d",&poso);
}

()
..
for ( i=0; i<=9; i++ )
printf("%d ",a[i] );


- .
,
, for.
..
#include <stdio.h>
/* mo - pinaka 1 x */
#define M 11
int p[];
int n,x,i;
float mo;


.
.
..
#include <stdio.h>
#define N 10
#define TRUE 1
#define FALSE 0
int a[N];
int i,found;
int timi;

main() {
scanf("%d",&n);
x=0;
for (i=1;i<=n;i++) {
printf("%d",p[i]);
x += p[i];
} /* for */
mo= (float)x/n;
printf("%f",mo);
}

main() {
found = FALSE;
scanf("%d", &timi );
i = 0;
while ( (!found) && (i < N) )
if ( a[i]==timi )
found = TRUE;
else i++;
if ( found ) printf("B
%d %d\n", a[i],i);
else printf(" \n");

() }

(
) Bubble
Sort ( ).
1
(L).
.
.
, DONE.

,
, .
..
#include <stdio.h>
#define N 10
#define TRUE 1
#define FALSE 0
int a[N];
int j, l, t, done;
main() {
l = N;
do
{
done = TRUE;
l--;
for(j=0; j<l; j++)
if(a[j] > a[j+1]) {
done = FALSE;
t = a[j];
a[j] = a[j+1];
a[j+1] = t;
}
}
while(!done);
}

(Binary Search)


,
.
.

, ,

. ,
. .
..
#include <stdio.h>
#define N 10
#define TRUE 1
#define FALSE 0
int
int
int
int

a[N];
i,found;
timi;
top,bot,mid;

main()
{
top = 0;
bot = N-1;
found = FALSE;
scanf("%d", &timi );
while((!found) && (top <= bot))
{
mid = (top+bot)/2;
if(a[mid] == timi)
found = TRUE;

else if(a[mid] > timi)
(Linear Search)
bot = mid-1;
else top = mid+1;
}
, if (found)
printf("B %d
.
%d\n", a[mid],mid);
else printf(" \n");

}

www.arnos.gr



( )

..
#define N 3
#define M 10
double f[N][M];
int i,j;
double a[N][N];
double sum1,sum2;


( )
for ( i = 0; i < N; i++ )
for ( j = 0; j < M; j++ )
f[i][j] = 0.0;

for
i, j
.

2 1
for(i=0; i < N; i++)
f[i][1] = f[i][1]+ 1;

(.. 3 = 1 + 2 )
for(j=0; j < M; j++ )
f[2][j]=f[0][j]+f[1][j];


for ( i=0; i < N; i++ ){
for ( j=0; j < M; j++ )
printf("%lf",f[i][j] );
printf("\n");
}




= .
i = j.
+ = -1 i + j = -1.
sum1 = sum2 = 0.0;
for ( i=0; i < N; i++ )
for ( j=0; j < ; j++ ) {
if (i == j)/* */
sum1 += a[i][j];
if ((i + j) == N-1)
/* */
sum2 += a[i][j];
}


#define M 2
#define L 2
#define N 2
main(){
int s,i,j,k;
int A[M][L]={{1,2},{3,4}};
int B[L][N]={{5,6},{7,8}},C[M][N];
for( i=0; i < M ; i++ )
for( j=0; j < N; j++ ){
for( k=0, s=0; k < L; k++ )
s+=A[i][k]*B[k][j];
C[i][j]=s;
}
for( i=0; i< M; i++ )
for( j=0; j < N; j++ )
printf("C[%d][%d] =
%3d\n",i,j,C[i][j]);
}

29  210.38.22.157 495
www.arnos.gr e-mail : info@arnos.gr

11

- SQL

SQL
SQL .
SQL
:

FROM
from .
.
: borrower x loan
select
from borrower, loan

Select A1, A2... An


from r1, r2... rm
where P
Ai .
ri .
P (
).

:

: ,
, Perryridge.

select customer-name, borrower.loannumber, amount


SQL from borrower, loan
.
where borrower.loan-number =
loan.loan-number and
branch-name = Perryridge
Branch (Branch-name, branch-city, assets)
Account (account-number, branch name, WHERE
balance)
where
Depositor (customer-name, account-number)

Customer (customer-name, customer. street, customer-city)
Borrower (customer-name, Loan-number)
Loan (Loan-number, Branch-name)
from.
SELECT
:
select -
. Perryridge
1200.

select loan-number
.
from loan
:
where branch-name = Perryridge and
loan.
amount > 1200
select branch-name

from loan
- and, or not.
:

branch-name(loan)
.

A1, A2, ..., An(P (r1x r2 x ... x rm))

select
. :
select *
from loan
:
loan
( )
select distinct branch-name
from loan
:
select loan-number, branch-name, amount 100
from loan

loan, amount, 100.

fast & easy


&


:

.
(Select customer-name
from depositor)
Union
(Select customer-name from borrower)
:

.
(Select customer-name
from depositor)
Intersect
(Select customer-name from borrower)
:
.
(Select customer-name from depositor)
Except
(Select customer-name from borrower)


.
avg: , min: , max:
,
sum: , count:

:
Perryridge.
Select avg (balance)
from account
where branch-name = Perryridge
:
customer.
select count (*)
from customer
: .
Select count (distinct customer-name)
from depositor

Group By:

.
:
select branch-name, count (distinct customer-name)
Perryridge.
from depositor, account
Select distinct customer-name
where depositor.account-number = acc
from borrower, loan
unt.account-number
where borrower. loan-number =
group by branch-name
loan.loan-number and
: select,
Branch-name = Perryridge

Order by customer-name
,

group by.
desc asc - Having:
.
default.
: Order by customer-name desc 1,200.

select branch-name, avg (balance)


from account
group by branch-name
having avg (balance) > 1200
: () having
groups,
where
groups.

select-fromwhere
,

.


, .
:

.
select distinct customer-name
from borrower
where customer-name in (select customername from depositor)
:
,
.
Select distinct customer-name
from borrower
where customer-name not in (select cus
omer-name
from depositor)
(VIEWS)
.
:
create view v
as < >
:
< >
v
:

create view all-customer as


(select branch-name, customer-name
from depositor, account
where depositor.account-number =
account.account-number)
union
(select branch-name, customer-name
from borrower, loan
where borrower.loan-number = loan.loannumber)
:
Perryridge
Select customer-name
from all-customer
where branch-name = Perryridge

SQL
char(n).

, n ( n
).
varchar(n). ,
n ( n ).
int. (
).
smallint. (
).
numeric(p,d). , p ( p
), n
.
real, double precision.
.
float(n). .
n .
date. , ,
.. date 2001-7-27
time. (, , ).
.. time 09:00:30 time 09:00:30.75
timestamp: +
.. timestamp 2001-7-27 09:00:30.75
Interval:
.. Interval 1 day

primary key (branch-name),


check (assets >= 0))
DROP KAI ALTER TABLE
drop table
.
alter table
.
null
.
alter table :
alter table r add A D


: Perryridge.
delete from account
where branch-name = Perryridge
:
account
insert into account
values (A-9732, Perryridge, 1200)

insert into account (branch-name, balance, account-number)


values (Perryridge, 1200, A-9732)
:

10,000 6%
date / time / ti 5%.
estamp interval update (
.
Interval ):
update account
date / time / timestamp
set balance = balance 1.06
CREATE TABLE
where balance > 10000
SQL - update account
set balance = balance 1.05
create table:
where balance 10000
Create table r (A1 D1, A2 D2, ..., An Dn,
:
( 1),...,

( k))
.
r
Ai delete from account
r
where balance < (select avg (balance)
Di from account)
Ai

:
decreate table branch
posit, avg balance
(branch-name char(15) not null,

branch-city char(30),

assets integer)
1 ( :
avg
)
not null
primary key (A1, ..., An)

check (P), P

: branch-name



branch

assets .

create table branch
.: 210.38.22.157 210.38.22.495
(branch-name
char(15),
branch-city
www.arnos.gr
char(30),assets integer,

You might also like