mysql命令

mysql命令行中,以分号(;)或者\g来结尾sql文。

\c来取消sql语句的输入


1,建立数据库cookbook

create database cookbook;


2,使用数据库cookbook

use cookbook


3,建立表limbs

create table limbs(thing varchar(20), legs int, arms int);


4,插入行

insert into limbs(thing,legs,arms) values('human',2,2);

insert into limbs(thing,legs,arms) values('insect',6,0);

insert into limbs(thing,legs,arms) values('squid',0,10);

insert into limbs(thing,legs,arms) values('octopus',0,8);

insert into limbs(thing,legs,arms) values('fish',0,0);

insert into limbs(thing,legs,arms) values('centipede',100,0);

insert into limbs(thing,legs,arms) values('table',4,0);

insert into limbs(thing,legs,arms) values('armchair',4,2);

insert into limbs(thing,legs,arms) values('phonograph',0,1);

insert into limbs(thing,legs,arms) values('tripod',3,0);

insert into limbs(thing,legs,arms) values('Peg Leg Pete',1,2);

insert into limbs(thing,legs,arms) values('space alien',NULL,NULL);


5,查询数据

select * from limbs;


6,取得当前时间

select now();


7, 查看mysql数据库版本和当前数据库

select version(), database();

 

 



 

你可能感兴趣的:(mysql)