要改变表中列的数据类型,请使用下面的语法:
SQL Server / MS Access:
ALTER TABLE table_name ALTER COLUMN column_name datatype
My SQL / Oracle:
ALTER TABLE table_name MODIFY COLUMN column_name datatype
sqllite,字符串拼接为 || 符号,不支持concat函数,mysql支持concat函数)
MySQL、SQL Server、Oracle等数据库支持CONCAT方法,
CONCAT方法:
select CONCAT(CONCAT(last_name," "),first_name) as name from employees
或者
select CONCAT(last_name," ",first_name) as name from employees
sqlite
select last_name||" "||first_name as name from employees
插入:
多条数据插入
mysql直接在后面拼多个记录
insert into actor
(actor_id,first_name,last_name,last_update)
values
(1,"PENELOPE","GUINESS","2006-02-15 12:34:33"),
(2,"NICK","WAHLBERG","2006-02-15 12:34:33");
Oracle中一次插入多条的方法:
方法一:采用union all拼接查询方式
方法二:采用insert all的方式
insert into pager (PAG_ID,PAG_PARENT,PAG_NAME,PAG_ACTIVE)
select 8000,0,'Multi 8000',1 from dual
union all select 8001,0,'Multi 8001',1 from dual
因为题目判定系统使用的是sqlite3,所以必须按sqlite3的写法来做,
insert or ignore into actor values(3,'ED','CHASE','2006-02-15 12:34:33');
如果是mysql,那么把or去掉,像下面这样:
insert IGNORE into actor values(3,'ED','CHASE','2006-02-15 12:34:33');