Administração
Por: Daniel Silva • 29/10/2015 • Monografia • 1.511 Palavras (7 Páginas) • 147 Visualizações
mysql> create database empresa;
Query OK, 1 row affected (0.02 sec)
mysql> use empresa;
Database changed
mysql> describe funcionario;
ERROR 1146 (42S02): Table 'empresa.funcionario' doesn't exist
mysql> create table funcionario (matricula int primary key auto_increment, nome
varchar (50) not null, endereco varchar (255) not null, telefone varchar (15) no
t null, idade int not null, salario decimal (10,2) not null, filhos int not null
);
Query OK, 0 rows affected (0.16 sec)
mysql> describe funcionario;
+-----------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+----------------+
| matricula | int(11) | NO | PRI | NULL | auto_increment |
| nome | varchar(50) | NO | | NULL | |
| endereco | varchar(255) | NO | | NULL | |
| telefone | varchar(15) | NO | | NULL | |
| idade | int(11) | NO | | NULL | |
| salario | decimal(10,2) | NO | | NULL | |
| filhos | int(11) | NO | | NULL | |
+-----------+---------------+------+-----+---------+----------------+
7 rows in set (0.02 sec)
mysql> insert into funcionario values ('','Daniel','Rua 1, n° 1','3000-3000','20
','1200.00','0');
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> select * from funcionario;
+-----------+--------+-------------+-----------+-------+---------+--------+
| matricula | nome | endereco | telefone | idade | salario | filhos |
+-----------+--------+-------------+-----------+-------+---------+--------+
| 1 | Daniel | Rua 1, n° 1 | 3000-3000 | 20 | 1200.00 | 0 |
+-----------+--------+-------------+-----------+-------+---------+--------+
1 row in set (0.00 sec)
mysql> insert into funcionario values ('','Dante','Rua 2, n° 2','3001-3001','19'
,'1250.00','1');
Query OK, 1 row affected, 1 warning (0.03 sec)
mysql> insert into funcionario values ('','Davi','Rua 3, n° 3','3002-3002','50',
'1300.00','0');
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> insert into funcionario values ('','Renata','Rua 4, n° 4','3003-3003','35
','1350.00','5');
Query OK, 1 row affected, 1 warning (0.03 sec)
mysql> insert into funcionario values ('','Renato','Rua 5, n° 5','3004-3004','18
','1400.00','0');
Query OK, 1 row affected, 1 warning (0.03 sec)
mysql> insert into funcionario values ('','José','Rua 6, n° 6','3005-3005','22',
'1450.00','5');
Query OK, 1 row affected, 1 warning (0.03 sec)
mysql> select nome,salario from where salario > 1000 and salario < 5000;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'where
salario > 1000 and salario < 5000' at line 1
mysql> describe funcionario;
+-----------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+----------------+
| matricula | int(11) | NO | PRI | NULL | auto_increment |
| nome | varchar(50) | NO | | NULL | |
| endereco | varchar(255) | NO | | NULL | |
| telefone | varchar(15) | NO | | NULL | |
| idade | int(11) | NO | | NULL | |
| salario | decimal(10,2) | NO | | NULL | |
| filhos | int(11) | NO | | NULL | |
+-----------+---------------+------+-----+---------+----------------+
7 rows in set (0.01 sec)
mysql> select nome,salario from funcionario where salario > 1000 and salario < 5
000;
+--------+---------+
|
...