찾다
데이터 베이스MySQL 튜토리얼Python中使用SQLAlchemy连接Mysql数据库2(多表连接操作)

http://blog.csdn.net/u011573853/article/details/51355113 在上面我们已经说了单表的一些操作,现在我们说一下多表的连接 from sqlalchemy import distinct from sqlalchemy.orm import aliased Astu = aliased(Stu, 'Astu' ) Acla = aliased(Cla, 'Acla'

http://blog.csdn.net/u011573853/article/details/51355113
在上面我们已经说了单表的一些操作,现在我们说一下多表的连接

<code class=" hljs python"><span class="hljs-prompt">>>> </span><span class="hljs-keyword">from</span> sqlalchemy <span class="hljs-keyword">import</span> distinct
<span class="hljs-prompt">>>> </span><span class="hljs-keyword">from</span> sqlalchemy.orm <span class="hljs-keyword">import</span> aliased
<span class="hljs-prompt">>>> </span>Astu = aliased(Stu,<span class="hljs-string">'Astu'</span>)
<span class="hljs-prompt">>>> </span>Acla = aliased(Cla,<span class="hljs-string">'Acla'</span>)
<span class="hljs-prompt">>>> </span>Agrade = aliased(Grade,<span class="hljs-string">'Agrade'</span>)</code>

在这里先用函数aliased()给表起一个别名以备使用

<code class=" hljs r"><span class="hljs-comment">#查询所有有成绩的学号</span>
>>> query = session.query(Stu).join(Grade,Stu.id==Grade.uid).all()
SELECT stu.id AS stu_id, stu.name AS stu_name 
FROM stu INNER JOIN grade ON stu.id = grade.uid
<span class="hljs-number">2016</span>-<span class="hljs-number">05</span>-<span class="hljs-number">10</span> <span class="hljs-number">15</span>:<span class="hljs-number">02</span>:<span class="hljs-number">36</span>,<span class="hljs-number">476</span> INFO sqlalchemy.engine.base.Engine ()
>>> <span class="hljs-keyword">for</span> re <span class="hljs-keyword">in</span> query:
<span class="hljs-keyword">...</span>     print re.id
<span class="hljs-keyword">...</span> 
<span class="hljs-number">1</span>
<span class="hljs-number">2</span>
<span class="hljs-number">3</span>
<span class="hljs-number">4</span>
<span class="hljs-number">5</span>
>>> </code>
<code class=" hljs cpp"><span class="hljs-preprocessor">#查找有成绩的同学的学号好成绩</span>
>>> print session.query(Grade.uid,Grade.gre).join(Stu,Grade.uid==Stu.id).all()
SELECT grade.uid AS grade_uid, grade.gre AS grade_gre 
FROM grade INNER JOIN stu ON grade.uid = stu.id
<span class="hljs-number">2016</span>-<span class="hljs-number">05</span>-<span class="hljs-number">10</span> <span class="hljs-number">15</span>:<span class="hljs-number">15</span>:<span class="hljs-number">22</span>,<span class="hljs-number">208</span> INFO sqlalchemy.engine.base.Engine ()
[(<span class="hljs-number">1L</span>, <span class="hljs-number">76L</span>), (<span class="hljs-number">1L</span>, <span class="hljs-number">76L</span>), (<span class="hljs-number">2L</span>, <span class="hljs-number">66L</span>), (<span class="hljs-number">2L</span>, <span class="hljs-number">76L</span>), (<span class="hljs-number">2L</span>, <span class="hljs-number">50L</span>), (<span class="hljs-number">3L</span>, <span class="hljs-number">96L</span>), (<span class="hljs-number">3L</span>, <span class="hljs-number">76L</span>), (<span class="hljs-number">3L</span>, <span class="hljs-number">60L</span>), (<span class="hljs-number">4L</span>, <span class="hljs-number">76L</span>), (<span class="hljs-number">4L</span>, <span class="hljs-number">76L</span>), (<span class="hljs-number">4L</span>, <span class="hljs-number">76L</span>), (<span class="hljs-number">5L</span>, <span class="hljs-number">66L</span>), (<span class="hljs-number">5L</span>, <span class="hljs-number">96L</span>), (<span class="hljs-number">5L</span>, <span class="hljs-number">96L</span>)]
>>> </code>
<code class=" hljs oxygene">#查找有成绩同学的学好成绩和课程名
>>>print session.query(Grade.uid,Grade.gre,Cla.cname).<span class="hljs-keyword">join</span>(Stu,Grade.uid==Stuid).<span class="hljs-keyword">join</span>(Cla,Grade.cid==Cla.id).all()
 <span class="hljs-keyword">SELECT</span> grade.uid <span class="hljs-keyword">AS</span> grade_uid, grade.gre <span class="hljs-keyword">AS</span> grade_gre, cla.cname <span class="hljs-keyword">AS</span> cla_cname 
<span class="hljs-keyword">FROM</span> grade INNER <span class="hljs-keyword">JOIN</span> stu <span class="hljs-keyword">ON</span> grade.uid = stu.id INNER <span class="hljs-keyword">JOIN</span> cla <span class="hljs-keyword">ON</span> grade.cid = cla.id
<span class="hljs-number">2016</span>-<span class="hljs-number">05</span>-<span class="hljs-number">10</span> <span class="hljs-number">15</span>:<span class="hljs-number">21</span>:<span class="hljs-number">29</span>,<span class="hljs-number">402</span> INFO sqlalchemy.engine.base.Engine ()
[(<span class="hljs-number">2</span>L, <span class="hljs-number">66</span>L, <span class="hljs-string">'yuwen'</span>), (<span class="hljs-number">5</span>L, <span class="hljs-number">66</span>L, <span class="hljs-string">'yuwen'</span>), (<span class="hljs-number">3</span>L, <span class="hljs-number">96</span>L, <span class="hljs-string">'shuxue'</span>), (<span class="hljs-number">2</span>L, <span class="hljs-number">50</span>L, <span class="hljs-string">'yingyu'</span>), (<span class="hljs-number">3</span>L, <span class="hljs-number">60</span>L, <span class="hljs-string">'yingyu'</span>), (<span class="hljs-number">4</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'yingyu'</span>), (<span class="hljs-number">5</span>L, <span class="hljs-number">96</span>L, <span class="hljs-string">'yingyu'</span>), (<span class="hljs-number">1</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'wuli'</span>), (<span class="hljs-number">3</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'wuli'</span>), (<span class="hljs-number">4</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'wuli'</span>), (<span class="hljs-number">1</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'huaxue'</span>), (<span class="hljs-number">2</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'huaxue'</span>), (<span class="hljs-number">4</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'huaxue'</span>), (<span class="hljs-number">5</span>L, <span class="hljs-number">96</span>L, <span class="hljs-string">'huaxue'</span>)]
>>> 
</code>
<code class=" hljs oxygene">#查找有成绩同学的学好成绩和课程名,并进行排序
>>> print session.query(Grade.uid,Grade.gre,Cla.cname).<span class="hljs-keyword">join</span>(Stu,Grade.uid==Stud).<span class="hljs-keyword">join</span>(Cla,Grade.cid==Cla.id).order_by(Grade.uid,Grade.gre.<span class="hljs-keyword">desc</span>()).all()
<span class="hljs-keyword">SELECT</span> grade.uid <span class="hljs-keyword">AS</span> grade_uid, grade.gre <span class="hljs-keyword">AS</span> grade_gre, cla.cname <span class="hljs-keyword">AS</span> cla_cname 
<span class="hljs-keyword">FROM</span> grade INNER <span class="hljs-keyword">JOIN</span> stu <span class="hljs-keyword">ON</span> grade.uid = stu.id INNER <span class="hljs-keyword">JOIN</span> cla <span class="hljs-keyword">ON</span> grade.cid = cla.id 
<span class="hljs-keyword">ORDER</span> <span class="hljs-keyword">BY</span> grade.uid, grade.gre <span class="hljs-keyword">DESC</span>
<span class="hljs-number">2016</span>-<span class="hljs-number">05</span>-<span class="hljs-number">10</span> <span class="hljs-number">15</span>:<span class="hljs-number">34</span>:<span class="hljs-number">17</span>,<span class="hljs-number">902</span> INFO sqlalchemy.engine.base.Engine ()
[(<span class="hljs-number">1</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'wuli'</span>), (<span class="hljs-number">1</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'huaxue'</span>), (<span class="hljs-number">2</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'huaxue'</span>), (<span class="hljs-number">2</span>L, <span class="hljs-number">66</span>L, <span class="hljs-string">'yuwen'</span>), (<span class="hljs-number">2</span>L, <span class="hljs-number">50</span>L, <span class="hljs-string">'yingyu'</span>), (<span class="hljs-number">3</span>L, <span class="hljs-number">96</span>L, <span class="hljs-string">'shuxue'</span>), (<span class="hljs-number">3</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'wuli'</span>), (<span class="hljs-number">3</span>L, <span class="hljs-number">60</span>L, <span class="hljs-string">'yingyu'</span>), (<span class="hljs-number">4</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'yingyu'</span>), (<span class="hljs-number">4</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'huaxue'</span>), (<span class="hljs-number">4</span>L, <span class="hljs-number">76</span>L, <span class="hljs-string">'wuli'</span>), (<span class="hljs-number">5</span>L, <span class="hljs-number">96</span>L, <span class="hljs-string">'yingyu'</span>), (<span class="hljs-number">5</span>L, <span class="hljs-number">96</span>L, <span class="hljs-string">'huaxue'</span>), (<span class="hljs-number">5</span>L, <span class="hljs-number">66</span>L, <span class="hljs-string">'yuwen'</span>)]
>>> 
</code>

<code class=" hljs avrasm">>>> query2=session<span class="hljs-preprocessor">.query</span>(Grade<span class="hljs-preprocessor">.uid</span>,Grade<span class="hljs-preprocessor">.gre</span>,Cla<span class="hljs-preprocessor">.cname</span>)<span class="hljs-preprocessor">.join</span>(Stu,Grade<span class="hljs-preprocessor">.uid</span>==Stid)<span class="hljs-preprocessor">.join</span>(Cla,Grade<span class="hljs-preprocessor">.cid</span>==Cla<span class="hljs-preprocessor">.id</span>)<span class="hljs-preprocessor">.order</span>_by(Grade<span class="hljs-preprocessor">.uid</span>,Grade<span class="hljs-preprocessor">.gre</span><span class="hljs-preprocessor">.desc</span>())<span class="hljs-preprocessor">.all</span>()
SELECT grade<span class="hljs-preprocessor">.uid</span> AS grade_uid, grade<span class="hljs-preprocessor">.gre</span> AS grade_gre, cla<span class="hljs-preprocessor">.cname</span> AS cla_cname 
FROM grade INNER JOIN stu ON grade<span class="hljs-preprocessor">.uid</span> = stu<span class="hljs-preprocessor">.id</span> INNER JOIN cla ON grade<span class="hljs-preprocessor">.cid</span> = cla<span class="hljs-preprocessor">.id</span> ORDER BY grade<span class="hljs-preprocessor">.uid</span>, grade<span class="hljs-preprocessor">.gre</span> DESC
<span class="hljs-number">2016</span>-<span class="hljs-number">05</span>-<span class="hljs-number">10</span> <span class="hljs-number">15</span>:<span class="hljs-number">37</span>:<span class="hljs-number">33</span>,<span class="hljs-number">628</span> INFO sqlalchemy<span class="hljs-preprocessor">.engine</span><span class="hljs-preprocessor">.base</span><span class="hljs-preprocessor">.Engine</span> ()
>>> for re <span class="hljs-keyword">in</span> query2:
...     print re<span class="hljs-preprocessor">.uid</span>,re<span class="hljs-preprocessor">.gre</span>,re<span class="hljs-preprocessor">.cname</span>
... 
<span class="hljs-number">1</span> <span class="hljs-number">76</span> wuli
<span class="hljs-number">1</span> <span class="hljs-number">76</span> huaxue
<span class="hljs-number">2</span> <span class="hljs-number">76</span> huaxue
<span class="hljs-number">2</span> <span class="hljs-number">66</span> yuwen
<span class="hljs-number">2</span> <span class="hljs-number">50</span> yingyu
<span class="hljs-number">3</span> <span class="hljs-number">96</span> shuxue
<span class="hljs-number">3</span> <span class="hljs-number">76</span> wuli
<span class="hljs-number">3</span> <span class="hljs-number">60</span> yingyu
<span class="hljs-number">4</span> <span class="hljs-number">76</span> yingyu
<span class="hljs-number">4</span> <span class="hljs-number">76</span> huaxue
<span class="hljs-number">4</span> <span class="hljs-number">76</span> wuli
<span class="hljs-number">5</span> <span class="hljs-number">96</span> yingyu
<span class="hljs-number">5</span> <span class="hljs-number">96</span> huaxue
<span class="hljs-number">5</span> <span class="hljs-number">66</span> yuwen
>>> 
</code>

只需要把你要查的字段写在query()中就好了

<code class=" hljs oxygene">#查找成绩小于等于<span class="hljs-number">70</span>同学的学好成绩和课程名,并进行排序
>>>print  session.query(Grade.uid,Grade.gre,Cla.cname).<span class="hljs-keyword">join</span>(Stu,Grade.uid==Stu.id).jn(Cla,Grade.cid==Cla.id).filter(Grade.gre<=<span class="hljs-number">70</span>).order_by(Grade.uid,Grade.gre.de()).all()
<span class="hljs-keyword">SELECT</span> grade.uid <span class="hljs-keyword">AS</span> grade_uid, grade.gre <span class="hljs-keyword">AS</span> grade_gre, cla.cname <span class="hljs-keyword">AS</span> cla_cname 
<span class="hljs-keyword">FROM</span> grade INNER <span class="hljs-keyword">JOIN</span> stu <span class="hljs-keyword">ON</span> grade.uid = stu.id INNER <span class="hljs-keyword">JOIN</span> cla <span class="hljs-keyword">ON</span> grade.cid = cla.id 
<span class="hljs-keyword">WHERE</span> grade.gre <= %s <span class="hljs-keyword">ORDER</span> <span class="hljs-keyword">BY</span> grade.uid, grade.gre <span class="hljs-keyword">DESC</span>
<span class="hljs-number">2016</span>-<span class="hljs-number">05</span>-<span class="hljs-number">10</span> <span class="hljs-number">15</span>:<span class="hljs-number">42</span>:<span class="hljs-number">06</span>,<span class="hljs-number">742</span> INFO sqlalchemy.engine.base.Engine (<span class="hljs-number">70</span>,)
[(<span class="hljs-number">2</span>L, <span class="hljs-number">66</span>L, <span class="hljs-string">'yuwen'</span>), (<span class="hljs-number">2</span>L, <span class="hljs-number">50</span>L, <span class="hljs-string">'yingyu'</span>), (<span class="hljs-number">3</span>L, <span class="hljs-number">60</span>L, <span class="hljs-string">'yingyu'</span>), (<span class="hljs-number">5</span>L, <span class="hljs-number">66</span>L, <span class="hljs-string">'yuwen'</span>)]
>>> </code>

<code class=" hljs r"><span class="hljs-comment">#用SQL语言来查询</span>
>>> query = session.execute(<span class="hljs-string">"select uid from grade where cid = (select id fromla where cname='yuwen')"</span>)
select uid from grade where cid = (select id from cla where cname=<span class="hljs-string">'yuwen'</span>)
<span class="hljs-number">2016</span>-<span class="hljs-number">05</span>-<span class="hljs-number">10</span> <span class="hljs-number">17</span>:<span class="hljs-number">12</span>:<span class="hljs-number">57</span>,<span class="hljs-number">395</span> INFO sqlalchemy.engine.base.Engine ()
>>> <span class="hljs-keyword">for</span> re <span class="hljs-keyword">in</span> query:
<span class="hljs-keyword">...</span>     print re.uid
<span class="hljs-keyword">...</span> 
<span class="hljs-number">2</span>
<span class="hljs-number">5</span>
>>> 
</code>
<code class=" hljs avrasm"><span class="hljs-preprocessor">#把学好为2成绩为100的学生成绩改为99</span>
>>> query5 = session<span class="hljs-preprocessor">.query</span>(Grade)
>>> query5<span class="hljs-preprocessor">.filter</span>(Grade<span class="hljs-preprocessor">.uid</span>==<span class="hljs-number">2</span>,Grade<span class="hljs-preprocessor">.gre</span>==<span class="hljs-number">100</span>)<span class="hljs-preprocessor">.update</span>({Grade<span class="hljs-preprocessor">.gre</span>:<span class="hljs-number">99</span>})
<span class="hljs-number">2016</span>-<span class="hljs-number">05</span>-<span class="hljs-number">10</span> <span class="hljs-number">16</span>:<span class="hljs-number">28</span>:<span class="hljs-number">46</span>,<span class="hljs-number">485</span> INFO sqlalchemy<span class="hljs-preprocessor">.engine</span><span class="hljs-preprocessor">.base</span><span class="hljs-preprocessor">.Engine</span> UPDATE grade <span class="hljs-keyword">SET</span> gre=%s WHERE grade<span class="hljs-preprocessor">.uid</span> = %s <span class="hljs-keyword">AND</span> grade<span class="hljs-preprocessor">.gre</span> = %s
<span class="hljs-number">2016</span>-<span class="hljs-number">05</span>-<span class="hljs-number">10</span> <span class="hljs-number">16</span>:<span class="hljs-number">28</span>:<span class="hljs-number">46</span>,<span class="hljs-number">486</span> INFO sqlalchemy<span class="hljs-preprocessor">.engine</span><span class="hljs-preprocessor">.base</span><span class="hljs-preprocessor">.Engine</span> (<span class="hljs-number">99</span>, <span class="hljs-number">2</span>, <span class="hljs-number">100</span>)
<span class="hljs-number">1</span>L</code>

此时没有提交还没有正在的改变

<code class=" hljs asciidoc"><span class="hljs-header">mysql> select * from grade where gre=100;
+----+------+------+------+</span>
<span class="hljs-header">| id | uid  | cid  | gre  |
+----+------+------+------+</span>
<span class="hljs-header">| 15 |    2 |    3 |  100 |
+----+------+------+------+</span>
1 row in set (0.00 sec)

>>> session.commit()
mysql> select * from grade where gre=100;
Empty set (0.00 sec)

也可以这样搞
>>> session.query(Grade).filter(Grade.gre==99).update({Grade.gre:50})
</code>

update里面使用的是字典类型
或这样搞

<code class=" hljs asciidoc">#用SQL语句把学语文的成绩都改为110
>>> session.execute("update grade set gre=110 where cid = (select id from cla ere cname=<span class="hljs-emphasis">'yuwen'</span>)")
<span class="hljs-code"> update grade set gre=110 where cid = (select id from cla where cname='yuwen')</span>
2016-05-10 17:15:59,383 INFO sqlalchemy.engine.base.Engine ()
<sqlalchemy.engine.result.ResultProxy object at 0xb5c895cc>
<span class="hljs-header">mysql> select * from grade where cid =(select id from cla where cname='yuwen');
+----+------+------+------+</span>
<span class="hljs-header">| id | uid  | cid  | gre  |
+----+------+------+------+</span>
|  2 |    2 |    1 |   66 |
<span class="hljs-header">|  3 |    5 |    1 |   66 |
+----+------+------+------+</span>
2 rows in set (0.00 sec)
#提交后
>>> session.commit()
2016-05-10 17:16:18,223 INFO sqlalchemy.engine.base.Engine COMMIT
>>> 
<span class="hljs-header">mysql> select * from grade where cid =(select id from cla where cname='yuwen');
+----+------+------+------+</span>
<span class="hljs-header">| id | uid  | cid  | gre  |
+----+------+------+------+</span>
|  2 |    2 |    1 |  110 |
<span class="hljs-header">|  3 |    5 |    1 |  110 |
+----+------+------+------+</span>
2 rows in set (0.00 sec)</code>
<code class=" hljs avrasm"><span class="hljs-preprocessor">#删除成绩为50的成绩记录</span>
>>> session<span class="hljs-preprocessor">.query</span>(Grade)<span class="hljs-preprocessor">.filter</span>(Grade<span class="hljs-preprocessor">.gre</span>==<span class="hljs-number">50</span>)<span class="hljs-preprocessor">.delete</span>()</code>
<code class=" hljs asciidoc">#删除选修英语的所有成绩记录,用SQL进行
>>> session.execute( "delete from grade where cid =(select id from cla where cme=<span class="hljs-emphasis">'yingyu'</span>)")
2016-05-10 16:55:55,472 INFO sqlalchemy.engine.base.Engine delete from grade where cid =(select id from cla where cname=<span class="hljs-emphasis">'yingyu'</span>)
2016-05-10 16:55:55,472 INFO sqlalchemy.engine.base.Engine ()
mysql> select * from grade where cid = (select id from cla where cname=<span class="hljs-emphasis">'yingyu'</span>)
<span class="hljs-header">    -> ;
+----+------+------+------+</span>
<span class="hljs-header">| id | uid  | cid  | gre  |
+----+------+------+------+</span>
|  5 |    5 |    3 |   96 |
|  9 |    4 |    3 |   76 |
<span class="hljs-header">| 14 |    3 |    3 |   60 |
+----+------+------+------+</span>
3 rows in set (0.00 sec)

>>> session.commit()
2016-05-10 16:56:33,075 INFO sqlalchemy.engine.base.Engine COMMIT
>>> 

mysql> select * from grade where cid = (select id from cla where cname=<span class="hljs-emphasis">'yingyu'</span>)
<span class="hljs-code">    -> ;</span>
Empty set (0.00 sec)</code>

级联删除:在relationship关联时要加上passive_deletes=True外键要加上ondelete=’CASCADE’,否则sqlalchemy不能级联删除
这些是多表连接的操作
单表的操作请看http://blog.csdn.net/u011573853/article/details/51355113
一些细节会在下面进行说明(事务,加锁,编码等)
http://blog.csdn.net/u011573853/article/details/51366124

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
MySQL 성능을 모니터링하는 데 사용할 수있는 몇 가지 도구는 무엇입니까?MySQL 성능을 모니터링하는 데 사용할 수있는 몇 가지 도구는 무엇입니까?Apr 23, 2025 am 12:21 AM

MySQL 성능을 효과적으로 모니터링하는 방법은 무엇입니까? Mysqladmin, Showglobalstatus, Perconamonitoring and Management (PMM) 및 MySQL Enterprisemonitor와 같은 도구를 사용하십시오. 1. MySQLADMIN을 사용하여 연결 수를보십시오. 2. showglobalstatus를 사용하여 쿼리 번호를보십시오. 3.pmm은 자세한 성능 데이터 및 그래픽 인터페이스를 제공합니다. 4. MySQLENTERPRISOMITOR는 풍부한 모니터링 기능 및 경보 메커니즘을 제공합니다.

MySQL은 SQL Server와 어떻게 다릅니 까?MySQL은 SQL Server와 어떻게 다릅니 까?Apr 23, 2025 am 12:20 AM

MySQL과 SqlServer의 차이점은 1) MySQL은 오픈 소스이며 웹 및 임베디드 시스템에 적합합니다. 2) SQLServer는 Microsoft의 상용 제품이며 엔터프라이즈 수준 애플리케이션에 적합합니다. 스토리지 엔진의 두 가지, 성능 최적화 및 응용 시나리오에는 상당한 차이가 있습니다. 선택할 때는 프로젝트 규모와 향후 확장 성을 고려해야합니다.

MySQL을 통해 어떤 시나리오에서 SQL Server를 선택할 수 있습니까?MySQL을 통해 어떤 시나리오에서 SQL Server를 선택할 수 있습니까?Apr 23, 2025 am 12:20 AM

고 가용성, 고급 보안 및 우수한 통합이 필요한 엔터프라이즈 수준의 응용 프로그램 시나리오에서는 MySQL 대신 SQLServer를 선택해야합니다. 1) SQLServer는 고 가용성 및 고급 보안과 같은 엔터프라이즈 수준의 기능을 제공합니다. 2) VisualStudio 및 Powerbi와 같은 Microsoft Ecosystems와 밀접하게 통합되어 있습니다. 3) SQLSERVER는 성능 최적화에서 우수한 성능을 발휘하며 메모리 최적화 된 테이블 및 열 스토리지 인덱스를 지원합니다.

MySQL은 문자 세트 및 콜라이트를 어떻게 처리합니까?MySQL은 문자 세트 및 콜라이트를 어떻게 처리합니까?Apr 23, 2025 am 12:19 AM

mysqlmanagesCharactersetsandcollationsUtf-8AsthedEfault, confonfigurationAtdatabase, 테이블 및 columnlevels, andcolumnlevels, andcolumnlevels, andcolumnlevels, 1) setDefaultCharactersetandcollationforadatabase.2) secigurecharactersetandcollation

MySQL의 트리거는 무엇입니까?MySQL의 트리거는 무엇입니까?Apr 23, 2025 am 12:11 AM

MySQL 트리거는 특정 데이터 작업이 수행 될 때 일련의 작업을 수행하는 데 사용되는 테이블과 관련된 자동 실행 된 저장 프로 시저입니다. 1) 트리거 정의 및 기능 : 데이터 검증, 로깅 등에 사용됩니다. 2) 작업 원칙 : 전후에 나누어지고 행 수준 트리거링을 지원합니다. 3) 사용의 예 : 급여 변경을 기록하거나 재고를 업데이트하는 데 사용할 수 있습니다. 4) 디버깅 기술 : ShowTriggers 및 ShowCreateTrigger 명령을 사용하십시오. 5) 성능 최적화 : 복잡한 작업을 피하고 인덱스 사용 및 거래 관리.

MySQL에서 사용자 계정을 어떻게 작성하고 관리합니까?MySQL에서 사용자 계정을 어떻게 작성하고 관리합니까?Apr 22, 2025 pm 06:05 PM

MySQL에서 사용자 계정을 작성하고 관리하는 단계는 다음과 같습니다. 1. 사용자 만들기 : CreateUser'Newuser '@'localhost'Identifiedby'Password '; 2. 권한 할당 : GrantSelect 사용, 삽입, UpdateOnmyDatabase.to'newuser'@'localhost '; 3. 권한 오류 수정 : Revokeallprivilegesonmydatabase.from'Newuser'@'localhost '; 그런 다음 권한을 재 할당합니다. 4. 최적화 권한 : showgra를 사용하십시오

MySQL은 Oracle과 어떻게 다릅니 까?MySQL은 Oracle과 어떻게 다릅니 까?Apr 22, 2025 pm 05:57 PM

MySQL은 빠른 개발 및 중소형 응용 프로그램에 적합한 반면 Oracle은 대기업 및 고 가용성 요구에 적합합니다. 1) MySQL은 오픈 소스이며 사용하기 쉬우 며 웹 응용 프로그램 및 중소 기업에 적합합니다. 2) Oracle은 강력하고 대기업 및 정부 기관에 적합합니다. 3) MySQL은 다양한 스토리지 엔진을 지원하며 Oracle은 풍부한 엔터프라이즈 수준의 기능을 제공합니다.

다른 관계형 데이터베이스와 비교하여 MySQL을 사용하는 단점은 무엇입니까?다른 관계형 데이터베이스와 비교하여 MySQL을 사용하는 단점은 무엇입니까?Apr 22, 2025 pm 05:49 PM

다른 관계형 데이터베이스와 비교하여 MySQL의 단점에는 다음이 포함됩니다. 1. 성능 문제 : 대규모 데이터를 처리 할 때 병목 현상을 만날 수 있으며 PostgreSQL은 복잡한 쿼리 및 빅 데이터 처리에서 더 잘 수행됩니다. 2. 확장 성 : 수평 스케일링 능력은 Google 스패너 및 Amazon Aurora만큼 좋지 않습니다. 3. 기능 제한 : 고급 기능에서 PostgreSQL 및 Oracle만큼 좋지 않으면 일부 기능에는 더 많은 사용자 정의 코드 및 유지 관리가 필요합니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

ZendStudio 13.5.1 맥

ZendStudio 13.5.1 맥

강력한 PHP 통합 개발 환경

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

VSCode Windows 64비트 다운로드

VSCode Windows 64비트 다운로드

Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)