sql 3

[mariaDB] 컬럼 추가, 삭제, 데이터 타입 변경

🔹 컬럼 추가ALTER TABLE `테이블명` ADD COLUMN `컬럼명` [데이터타입];alter table `tour` add column `tour_region` varchar(255) not null; 🔹 컬럼 삭제ALTER TABLE `테이블명` DROP COLUMN `컬럼명`;alter table `preference` drop column `prefer_with`; 🔹 컬럼 데이터 타입 변경ALTER TABLE `테이블명` MODIFY `컬럼명` [데이터타입];alter table `tour` modify `tour_interest` varchar(255) not null;cf) mysql; alter table 테이블명 alter column 컬럼명 데이터타입; 🔹 데이터 타입 확..

sql 2025.02.06

ALTER TABLE `tourdays` DROP FOREIGN KEY `FK_Tour_TO_TourDays_1`;

ALTER TABLE 'tourdays' DROP FOREIGN KEY 'FK_Tour_TO_TourDays_1'; SQL Error [1064] [42000]: (conn=62) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''tourdays' drop foreign key 'FK_Tour_TO_TourDays_1'' at line 1 수정 후 :ALTER TABLE `tourdays` DROP FOREIGN KEY `FK_Tour_TO_TourDays_1`; ❤  SQL에서는 테이블명과 제약조건명을 백틱(..

sql 2025.02.05