连接mysql数据库命令:mysql -u root -p
创建mysql数据库:create databaase xx库;
创建mysql表:
create table db_xx表(
id int primary key auto_increment,
name varchar(64) not null,
address varchar(16) not null,
salary decimal(9,2),
createtime
----建表操作
create table db_Job(
id int primary key auto_increment,
createtime datetime DEFAULT CURRENT_TIMESTAMP,
updatetime datetime default null,
startime timestamp NOT NULL default CURRENT_TIMESTAMP,
endtime datetime default NULL
state int(10)
);
----查看表结构
desc xx表名;
----查看版本号
新增 insert into xx表(字段1,字段2....)values('值1' , '值2',....)
修改 update db_job set state='999' where id=1;
删除 delete from db_job where state=999;
查询 select * from db_job where state=398;
新增某一字段:alter table db_job add column name varchar(16)
修改某一字段名称:alter table db_job change 老字段名 新字段名 varchar(32); 新字段类型
修改某一字段值:update t8 set name="demo" where id=1;
删除某一字段:alter table db_job drop name;
修改表名:rename table 老表名 to 新表名;
修改库名:RENAME DATABASE db_name TO new_db_name
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------