举一反三
- 以下PHP代码,用来查询mysql数据库中的User表,若能正常连接数据库,则以下选项中能正确执行$sql的查询语句的是()[br][/br][?php<br]……[br][/br]$conn = new mysqli($servername, $username, $password, $dbname);[br][/br]$sql ="select * from User";[br][/br]( ); A: mysqli_query($conn, $sql); B: $conn->execute($sql); C: $conn->query($sql); D: query($sql);
- 给定如下Java代码片段,假定已经获得一个数据库连接,使用变量conn来表示。要从表FirstLevelTitle中删除所有creeator列值为“张三”的记录(creator字段的数据类型为varchar),可以填入下划线处的代码是( )。[br][/br]String strSql =”delete from FirstLevelTitle where creator = ?”;[br][/br]preparedStatement pstmt = con.prepareStatement(strSql);[br][/br]_________[br][/br]Pstmt. executeUpdate (); A: pstmt.setString(0,”张三”); B: pstmt.setString(1,”张三”); C: pstmt.setInt(0,”张三”); D: pstmt.setInt(1,”张三”);
- 已知,存在 QueryRunner对象 runner ,SQL语句: String sql = "delete from user where id=?"; 下面操作中,能实现删除记录id=1的操作是()
- 对下列程序代码理解正确的是 [?php$conn = Mysqli_connect(“localhost”,”root”,”123456”,”test”) or die(“数据库连接失败!”);$sql = “select id,name,age,sex,phone,email from user where age]20 and sex=’男’”;$result = mysqli_query($conn,$sql);while($row = mysqli_fetch_assoc($result)){echo $row[‘id’].’[br][/br]’;}Mysqli_close($conn);?> A: 数据库连接失败时,将显示“数据库连接失败”并退出程序。 B: 可以获得user表中所有年龄超过20的男生信息。 C: 在浏览器中输出年龄超过20的男生id。 D: 改代码最后没有释放资源。
- 要删除book表中书籍(bookName)是”java”的记录,横线上应填写的正确代码的是 ( )<br/>String sql=”delete from book where bookName=?”;<br/>PreparedStatement pst=con.preparedStatement(sql);<br/>______________________________<br/>pst.execute(); A: pst.setString(1,”java”); B: pst.setString(0,”java”); C: pst.setInt(0,”java”); D: 以上选项都不正确
内容
- 0
已知,存在 QueryRunner对象 runner ,SQL语句: String sql = "delete from user where id=?"; 下面操作中,能实现删除记录id=1的操作是() A: int num =runner.delete(sql, 1); B: int num =runner.update(sql, 1); C: Object num =runner.delete(1, sql); D: Object num =runner.update(1, sql);
- 1
已知,存在 QueryRunner对象 runner ,SQL语句:String sql = "delete from user where id=?";下面操作中,能实现删除记录id=1的操作是( ) A: Object num =runner.update(1, sql); B: Object num =runner.delete(1, sql); C: int num =runner.delete(sql, 1); D: int num =runner.update(sql, 1);
- 2
删除student表中id为1的记录,下列语句正确的是 A: DELETE student WHERE id=1; B: DELETE FROM student WHERE id=1; C: DELETE FROM student WHERE id:=1; D: DELETE student WHERE id:=1;
- 3
删除student表中id为1的记录() A: TRUNCATE FROM student where id=1; B: DELETE student where id=1; C: DELETE FROM student where id=1; D: DELETE INTO student where id=1;
- 4
假定已经获得一个数据库连接,使用变量conn来表示。下列语句中能够正确获得结果集的有__1__。(选择两项)[br][/br] A.Statement stmt = conn.createStatement()__2__;[br][/br] ResultSet rs = stmt.executeQuery(“SELECT * FROM STUDENT”);[br][/br] B.Statement stmt = conn.createStatement(“SELECT * FROM STUDENT”);[br][/br] ResultSet rs = stmt.executeQuery()__3__;[br][/br] C.PreparedStatement stmt = conn.prepareStatement()__4__;[br][/br] ResultSet rs = stmt.executeQuery(“SELECT * FROM STUDENT”);[br][/br] D.PreparedStatement stmt = conn.prepareStatement(“SELECT * FROM STUDENT”);[br][/br] ResultSet rs = stmt.executeQuery()__5__;