컴퓨터/mysql

mysql-opentutorials

풍경소리^^ 2019. 10. 13. 02:37

https://opentutorials.org/course/3161

mysql -uroot -p

show databases;

create database opentutorials;

use opentutorials;

show tables;

검색 create table in my cheat sheet

mysql> create table topic(
    -> id int(11) not null auto_increment,
    -> title varchar(100) not null,
    -> description text null,
    -> created datetime not null,
    -> author varchar(15) null,
    -> profile varchar(200) null,
    -> primary key(id)
    -> );

desc topic;

insert into topic (title,description,created,author,profile) values('MySQL','MySQL is ...',now(),'egoing','developer');

select *  from topic;

select id,title,created,autor from topic;

select "egoing"

select "egoing",1+1;

select id, title,created,author from topic where author='egoing';

select id, title,created,author from topic where author='egoing' order by id desc;

select id, title,created,author from topic where author='egoing' order by id desc limit 2;

update topic set description='Oracle is ...', title='Oracle' where id=2;

delete from topic where id=5;

rename table topic to topic_backup;

mysql> create table topic(
    -> id int(11) not null auto_increment,
    -> title varchar(100) not null,
    -> description text null,
    -> created datetime not null,
    -> author_id int(11) null,
    -> primary key(id)
    -> );

desc topic;

mysql> create table author(
    -> id int(11) not null auto_increment,
    -> name varchar(20) not null,
    -> profile varchar(200) null,
    -> primary key(id)
    -> );

mysql> insert into author (id, name, profile) values (1,'egoing','developer');
mysql> insert into topic (id, title, description, created, author_id)

    -> values (1,'MySQL','MySQL is ...', '2018-01-01 12:10:11', 1);

mysql> select * from topic left join author on topic.author_id = author.id;

mysql> select topic.id as topic_id,title,description,created,name,profile from topic left join author

    ->on topic.author_id = author.id;

mysql> update author set profile='database administrator' where id=2;

검색 mysql client

mysql workbench

mysql -u root -p -h localhost

mysql -u root -p -h 127.0.0.1