sábado, 18 de abril de 2009

Mysql - Dicas

-> Definindo senha root mysql
#mysql -D mysql -u root -p
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 34
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> update user set Password=PASSWORD('senhaRootAqui') where User='root';
mysql> flush privileges;
mysql> quit;


-> Criando tabela.
mysql> create table aluno (
serie varchar(40),
nome varchar(50),
teste vachar(255)
);

-> Adicionando colunas na tabela.
mysql> alter table aluno add idade int(3) ;

-> Deletando coluna "teste" da tabela aluno,
mysql> alter table aluno drop teste;

-> Apagando Registros
mysql> delete from aluno where serie="2";

-> Adicionando configuração á um campo da table:
alter table aluno add primary key(serie) ;

-> Removendo chaves primaria da tabela:
alter table aluno drop index serie;

-> Adicionando uma coluna no primeiro campo da tabela:
alter table aluno add id int(11) not null fist;

-> Adicionando uma coluna apos uma que você queira:
alter table aluno add teste2 varchar(33) not null after serie;

Nenhum comentário: