CREATE TABLE music ( - CREATE TABLE music (
- id INT PRIMARY KEY AUTO_INCREMENT,
- title VARCHAR(255) NOT NULL,
- artist VARCHAR(255) NOT NULL,
- album VARCHAR(255),
- release_date DATE,
- genre VARCHAR(255), length TIME,
- size INT,
- file_path VARCHAR(255) NOT NULL );
Bu kodlar yordamida, "music" nomli jadval yaratildi. Jadvalda "id" nomli birinchi ustun avtomatik tartiblash (auto-increment), "title" va "artist" nomli ustunlar bo'sh bo'lishi mumkin emas ("NOT NULL"), "album" nomli ustun bo'sh bo'lishi mumkin. INSERT INTO music (title, artist, album, release_date, genre, length, size, file_path) - INSERT INTO music (title, artist, album, release_date, genre, length, size, file_path)
- VALUES
- ('Bohemian Rhapsody', 'Queen', 'A Night at the Opera', '1975-10-31', 'Rock', '00:05:55', 12771000, 'C:/Music/Queen/Bohemian_Rhapsody.mp3'),
- ('Stairway to Heaven', 'Led Zeppelin', 'Led Zeppelin IV', '1971-11-08', 'Rock', '00:08:02', 19586500, 'C:/Music/Led_Zeppelin/Stairway_to_Heaven.mp3'),
- ('Hotel California', 'Eagles', 'Hotel California', '1976-12-08', 'Rock', '00:06:30', 14640000, 'C:/Music/Eagles/Hotel_California.mp3'),
- ('Smells Like Teen Spirit', 'Nirvana', 'Nevermind', '1991-09-10', 'Grunge', '00:05:01', 11902000, 'C:/Music/Nirvana/Smells_Like_Teen_Spirit.mp3');
Bu kodlar yordamida, "music" nomli jadvalga bo'sh joyga ma'lumotlar qo'shiladi. Jadvalga qo'shilayotgan ma'lumotlar "INSERT INTO" so'z yordamida belgilanadi. Jadval ustunlari nomi (title, artist, album, release_date, genre, length, size, file_path) ma'lumotlar bilan birgalikda belgilanadi. Maydon qiymatlarini boshqarish uchun quyidagi SQL so'rovlaridan foydalanish mumkin: Maydon qiymatlarini boshqarish uchun quyidagi SQL so'rovlaridan foydalanish mumkin: Jadval ustunining nomini o'zgartirish: - ALTER TABLE music
- CHANGE COLUMN title song_title VARCHAR(255);
Do'stlaringiz bilan baham: |