MySQL一招入門
連接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
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
MySQL一招入門