Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
Adds column
author_id
to the table
note
after
title
column
ALTER TABLE note
ADD COLUMN author_id int not null default 0 AFTER title;
by Valeri Tandilashvili
4 years ago
0
MySQL
ALTER TABLE
Full MySQL Course for Beginners
1
Changes the column type to
VARCHAR(200)
ALTER TABLE note
MODIFY COLUMN title VARCHAR(200) NOT NULL;
by Valeri Tandilashvili
4 years ago
0
MySQL
ALTER TABLE
Full MySQL Course for Beginners
1
Renames the column
name
to
title
ALTER TABLE note CHANGE name title VARCHAR(210)
by Valeri Tandilashvili
4 years ago
0
MySQL
ALTER TABLE
Full MySQL Course for Beginners
1
Deletes column
title
from table
note
ALTER TABLE note 
DROP COLUMN title;
COLUMN
is optional. The following query is alternative to the first one:
ALTER TABLE note 
DROP title;
by Valeri Tandilashvili
4 years ago
0
MySQL
ALTER TABLE
Full MySQL Course for Beginners
1
ALTER TABLE note
CHANGE COLUMN title title VARCHAR(210) AFTER author_id
Another way to do the same thing is to use
MODIFY
instead of
CHANGE
ALTER TABLE note
MODIFY COLUMN title VARCHAR(210) AFTER description
by Valeri Tandilashvili
4 years ago
0
MySQL
ALTER TABLE
Full MySQL Course for Beginners
1
Set column at the top
Makes the column first - sets it at the top
ALTER TABLE note
CHANGE COLUMN title title VARCHAR(210) FIRST
The same thing using
MODIFY
ALTER TABLE note
MODIFY COLUMN title VARCHAR(210) FIRST
by Valeri Tandilashvili
4 years ago
0
MySQL
ALTER TABLE
1
IN
Selects all students that has one of the following last names
გოგია
გაგუა
გოგუა
SELECT *
FROM students
WHERE last_name IN ('გოგია', 'გაგუა', 'გოგუა')
Filtering the result using
IN
with sub-query:
SELECT
    *
FROM
    students
WHERE
    last_name IN(
        SELECT
            last_name
        FROM
            students
        WHERE
            id <= 5
    )
Alternative of the query using
=
operator:
SELECT *
FROM students
WHERE last_name = 'გოგია' 
OR last_name = 'გაგუა'
OR last_name = 'გოგუა'
by Valeri Tandilashvili
4 years ago
0
MySQL
IN
1
FOREIGN KEY
FOREIGN KEY
constraint protects data integrity. Let's create
students
and
note
tables
USE university;
DROP TABLE IF EXISTS students;
CREATE TABLE students (
    id int AUTO_INCREMENT,
    first_name varchar(50),
    last_name varchar(50),
    PRIMARY KEY(id)
);
Let's add
FOREIGN KEY
called
fk_student_note
to the
notes
table
DROP TABLE IF EXISTS notes;
CREATE TABLE notes (
    id int AUTO_INCREMENT,
    student_id int,
    title varchar(50),
    description varchar(50),
    PRIMARY KEY(id),
    INDEX(student_id),
    CONSTRAINT fk_student_note  
        FOREIGN KEY (student_id)  
        REFERENCES students(id) 
        ON UPDATE CASCADE 
        ON DELETE RESTRICT
);
by Valeri Tandilashvili
4 years ago
0
MySQL
1
Differences between NO ACTION and RESTRICT
NO ACTION
is equivalent to RESTRICT. The MySQL Server rejects the delete and update operations of the parent table if there is a related foreign key value in the referenced table
by Valeri Tandilashvili
4 years ago
0
MySQL
FOREIGN KEY
1
Delete FOREIGN KEY by its name
ALTER TABLE notes 
DROP FOREIGN KEY fk_student_note`;
by Valeri Tandilashvili
4 years ago
0
MySQL
ALTER TABLE
1
Results: 1580