Mysql 명령어

coc·2024년 4월 12일
0
  • 데이터 베이스 생성
    CREATE DATABASE [만들 데이터베이스 이름];

  • 유저 생성
    create user [유저 이름] @ localhost identfied by '[비번]';

  • 모든 권한 부여
    grant all privaileges on [만든 데이터베이스 이름].* to [유저 이름]@localhost

  • 가지고 있는 데이터베이스 목록을 확인
    show databases;
  • 작업할 데이터베이스를 선택
    USE [데이터베이스 이름];

  • 현재 데이터베이스가 무엇인지 확인
    SELECT database();

  • 컬럼명과 type을 볼수 있다
    show columns from [테이블 이름];
    또는 DESC [테이블 이름];

  • 테이블 종류 확인
    show tables;

  • 테이블 삭제
    DROP TABLE [테이블 이름];

  • Not null
    create table [테이블 이름]
    (
    [컬럼명] 타입 not null,
    [컬럼명] 타입 not null
    );
    ex) create table cats2
    (
    name varchar(100) not null,
    age int not null
    );

  • DEFAULT
    create table [테이블이름](
    [컬럼명] 타입 default 고정값,
    [컬럼명] 타입 default 고정값
    );
    ex) create table cats3(
    name varchar(50) default 'mystery',
    age int default 99
    );

  • primary key
    create table unique_cats(
    [컬러명] 타입 not null primary key
    );
    ex) create table unique_cats(
    cat_id int not null primary key,
    name varchar(100),
    age int
    );
profile
시작

0개의 댓글

관련 채용 정보