2018 m. vasario 25 d., sekmadienis

mysql creating table

Creating database with auto_incrementing id:

CREATE TABLE test (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(20),
        nickname VARCHAR(20),
PRIMARY KEY(id)
);


Inserting values:

INSERT INTO test (name, nickname) VALUES("John", "Fire");


Updating values: (for multiple values put comma, after each SET clouse

UPDATE test 
SET vardas = 'Power'
WHERE id = 1;

Deleting values:

DELETE FROM test WHERE id = 11;

Adding additional rows in table:

ALTER TABLE test ADD comment VARCHAR(100);

Dropping column:

ALTER TABLE test DROP COLUMN comment;


Resources:
https://www.youtube.com/watch?v=nWeW3sCmD2k - SQL Crash Course - Beginner to Intermediate
https://www.youtube.com/watch?v=Thd8yoBou7k - MYSQL for pyhon developers