sql進階操作

來源:互聯網
上載者:User

同樣也是用於記錄以便日後聯絡用!裡面基本包含了一般sql的進階用法!

drop table if exists stu;create table stu(name varchar(30),age int,stuid int not null PRIMARY key AUTO_INCREMENT,idnum int,sex varchar(30),check(sex in ('男','女')))charset=utf8;insert into stu (name,age,idnum,sex)VALUES('damon',789,4678945,'男');insert into stu (name,age,idnum,sex) VALUES('coco',13,345,'女');insert into stu (name,age,idnum,sex)values('kitty',13,46,'女');insert into stu (name,age,idnum,sex)values('alice',14,123,'女');SELECT * from stu;select * from stu limit 0,2;select * from stu where name like '%ce';select * from stu where name REGEXP "a[sfdl][^ads]";select * from stu where name in ('damon','alice');select * from stu where name BETWEEN 'coco' and 'kitty'; select * from stu where name not between 'coco' and 'kitty';select name as stuname,stuid as id from stu;drop view if EXISTS young_stu;create view young_stu asselect name,age from stu where age between 10 and 20;select * from young_stu where age is not null;

後面會再記錄一章專門使用sql函數。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.